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   1225 use feature ':5.10';
  59         110  
  59         4980  
3 59     59   314 use strict;
  59         1001  
  59         1100  
4 59     59   255 use warnings;
  59         119  
  59         14943  
5              
6 14     14 1 666 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 1570     1570 1 7616 my $class = shift;
15 1570   50     3360 my $argv1 = shift // return undef;
16              
17 1570         2125 state $index = [
18             'message header size exceeds limit',
19             'message too large',
20             ];
21 1570 100       3544 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  3140         7296  
22 1569         3457 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 1812     1812 0 2863 my $class = shift;
33 1812   100     4630 my $argvs = shift // return undef;
34              
35 1811 100       4070 return undef unless $argvs->deliverystatus;
36 1416 50       7468 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 1416 100 100     6788 return 1 if (Sisimai::SMTP::Status->name($argvs->deliverystatus) || '') eq 'exceedlimit';
42              
43             # Check the value of Diagnosic-Code: header with patterns
44 1403 50       3352 return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
45 1403         4631 return 0;
46             }
47              
48             1;
49             __END__