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   1219 use feature ':5.10';
  59         100  
  59         3973  
3 59     59   309 use strict;
  59         107  
  59         1049  
4 59     59   249 use warnings;
  59         108  
  59         12711  
5              
6 1     1 1 599 sub text { 'hasmoved' }
7 4     4 0 16 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 8938 my $class = shift;
15 2207   50     4754 my $argv1 = shift // return undef;
16              
17 2207         3229 state $index = [' has been replaced by '];
18 2207 100       4193 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  2207         6437  
19 2206         4745 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 3429 my $class = shift;
30 1784   100     3910 my $argvs = shift // return undef;
31              
32 1783 50       3735 return 1 if $argvs->reason eq 'hasmoved';
33 1783 50       9292 return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
34 1783         4684 return 0;
35             }
36              
37             1;
38             __END__