File Coverage

lib/Sisimai/Reason/HasMoved.pm
Criterion Covered Total %
statement 22 22 100.0
branch 4 6 66.6
condition 3 4 75.0
subroutine 7 7 100.0
pod 2 4 50.0
total 38 43 88.3


line stmt bran cond sub pod time code
1             package Sisimai::Reason::HasMoved;
2 59     59   1048 use feature ':5.10';
  59         91  
  59         3690  
3 59     59   313 use strict;
  59         87  
  59         1008  
4 59     59   243 use warnings;
  59         107  
  59         11066  
5              
6 1     1 1 677 sub text { 'hasmoved' }
7 4     4 0 15 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 2243     2243 1 8491 my $class = shift;
15 2243   50     4643 my $argv1 = shift // return undef;
16              
17 2243         2468 state $index = [' has been replaced by '];
18 2243 100       3027 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  2243         6365  
19 2242         4855 return 0;
20             }
21              
22             sub true {
23             # Whether the address has moved or not
24             # @param [Sisimai::Data] 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 1816     1816 0 2967 my $class = shift;
30 1816   100     3791 my $argvs = shift // return undef;
31              
32 1815 50       3703 return 1 if $argvs->reason eq 'hasmoved';
33 1815 50       8569 return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
34 1815         3901 return 0;
35             }
36              
37             1;
38             __END__