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   1274 use feature ':5.10';
  59         106  
  59         5085  
3 59     59   340 use strict;
  59         116  
  59         1198  
4 59     59   298 use warnings;
  59         147  
  59         16169  
5              
6 14     14 1 57 sub text { 'exceedlimit' }
7 4     4 0 13 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 8247 my $class = shift;
15 1570   50     3282 my $argv1 = shift // return undef;
16              
17 1570         2851 state $index = [
18             'message header size exceeds limit',
19             'message too large',
20             ];
21 1570 100       2687 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  3140         7864  
22 1569         3922 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 2676 my $class = shift;
33 1812   100     4297 my $argvs = shift // return undef;
34              
35 1811 100       3467 return undef unless $argvs->deliverystatus;
36 1416 50       7723 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     7631 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       3441 return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
45 1403         3899 return 0;
46             }
47              
48             1;
49             __END__