File Coverage

lib/Sisimai/Reason/HasMoved.pm
Criterion Covered Total %
statement 23 23 100.0
branch 6 6 100.0
condition 4 4 100.0
subroutine 7 7 100.0
pod 2 4 50.0
total 42 44 95.4


line stmt bran cond sub pod time code
1             package Sisimai::Reason::HasMoved;
2 64     64   2062 use v5.26;
  64         255  
3 64     64   367 use strict;
  64         499  
  64         4217  
4 64     64   325 use warnings;
  64         162  
  64         19137  
5              
6 1     1 1 5 sub text { 'hasmoved' }
7 4     4 0 22 sub description { "Email rejected due to user's mailbox has moved and is not forwarded automatically" }
8             sub match {
9             # Try to match that the given text and regular expressions
10             # @param [String] argv1 String to be matched with regular expressions
11             # @return [Integer] 0: Did not match
12             # 1: Matched
13             # @since v4.1.25
14 2337     2337 1 6268 my $class = shift;
15 2337   100     11195 my $argv1 = shift // return 0;
16              
17 2336         4089 state $index = [' has been replaced by '];
18 2336 100       5732 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  2336         8457  
19 2334         7930 return 0;
20             }
21              
22             sub true {
23             # Whether the address has moved or not
24             # @param [Sisimai::Fact] argvs Object to be detected the reason
25             # @return [Integer] 1: The address has moved
26             # 0: Has not moved
27             # @since v4.1.25
28             # @see http://www.ietf.org/rfc/rfc2822.txt
29 2026     2026 0 4405 my $class = shift;
30 2026   100     8285 my $argvs = shift // return 0;
31              
32 2025         8256 require Sisimai::SMTP::Command;
33 2025 100       6907 return 1 if $argvs->{'reason'} eq 'hasmoved';
34 2024 100       10192 return 0 if grep { $argvs->{'command'} eq $_ } Sisimai::SMTP::Command->BeforeRCPT->@*;
  12144         26544  
35 1828         8347 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
36             }
37              
38             1;
39             __END__