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   1248 use feature ':5.10';
  59         103  
  59         4273  
3 59     59   379 use strict;
  59         96  
  59         1207  
4 59     59   268 use warnings;
  59         116  
  59         14316  
5              
6 1     1 1 5 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 2207     2207 1 8457 my $class = shift;
15 2207   50     4035 my $argv1 = shift // return undef;
16              
17 2207         2500 state $index = [' has been replaced by '];
18 2207 100       3125 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  2207         6758  
19 2206         4751 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 1784     1784 0 2699 my $class = shift;
30 1784   100     3663 my $argvs = shift // return undef;
31              
32 1783 50       3420 return 1 if $argvs->reason eq 'hasmoved';
33 1783 50       8718 return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
34 1783         4587 return 0;
35             }
36              
37             1;
38             __END__