File Coverage

lib/Sisimai/Reason/ExceedLimit.pm
Criterion Covered Total %
statement 24 24 100.0
branch 8 10 80.0
condition 5 6 83.3
subroutine 7 7 100.0
pod 2 4 50.0
total 46 51 90.2


line stmt bran cond sub pod time code
1             package Sisimai::Reason::ExceedLimit;
2 59     59   1075 use feature ':5.10';
  59         102  
  59         4768  
3 59     59   276 use strict;
  59         100  
  59         953  
4 59     59   223 use warnings;
  59         110  
  59         14292  
5              
6 14     14 1 29 sub text { 'exceedlimit' }
7 4     4 0 14 sub description { 'Email rejected due to an email exceeded the limit' }
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.0.0
14 1602     1602 1 6431 my $class = shift;
15 1602   50     3361 my $argv1 = shift // return undef;
16              
17 1602         1865 state $index = [
18             'message header size exceeds limit',
19             'message too large',
20             ];
21 1602 100       2118 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  3204         6349  
22 1601         3272 return 0;
23             }
24              
25             sub true {
26             # Exceed limit or not
27             # @param [Sisimai::Data] argvs Object to be detected the reason
28             # @return [Integer] 1: Exceeds the limit
29             # 0: Did not exceed the limit
30             # @since v4.0.0
31             # @see http://www.ietf.org/rfc/rfc2822.txt
32 1844     1844 0 2733 my $class = shift;
33 1844   100     3684 my $argvs = shift // return undef;
34              
35 1843 100       3484 return undef unless $argvs->deliverystatus;
36 1448 50       6799 return 1 if $argvs->reason eq 'exceedlimit';
37              
38             # Delivery status code points "exceedlimit".
39             # Status: 5.2.3
40             # Diagnostic-Code: SMTP; 552 5.2.3 Message size exceeds fixed maximum message size
41 1448 100 100     5927 return 1 if (Sisimai::SMTP::Status->name($argvs->deliverystatus) || '') eq 'exceedlimit';
42              
43             # Check the value of Diagnosic-Code: header with patterns
44 1435 50       3512 return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
45 1435         4185 return 0;
46             }
47              
48             1;
49             __END__