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 68     68   1601 use v5.26;
  68         173  
3 68     68   460 use strict;
  68         85  
  68         1283  
4 68     68   203 use warnings;
  68         101  
  68         15800  
5              
6 1     1 1 7 sub text { 'hasmoved' }
7 4     4 0 21 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 2419     2419 1 4912 my $class = shift;
15 2419   100     4113 my $argv1 = shift // return 0;
16              
17 2418         2458 state $index = [' has been replaced by '];
18 2418 100       3276 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  2418         5233  
19 2416         4893 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 2103     2103 0 3062 my $class = shift;
30 2103   100     4076 my $argvs = shift // return 0;
31              
32 2102         4951 require Sisimai::SMTP::Command;
33 2102 100       4250 return 1 if $argvs->{'reason'} eq 'hasmoved';
34 2101 100       6285 return 0 if grep { $argvs->{'command'} eq $_ } Sisimai::SMTP::Command->BeforeRCPT->@*;
  12606         15770  
35 1905         6049 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
36             }
37              
38             1;
39             __END__