lib/Mail/DMARC/Report/Aggregate/Record/Auth_Results/DKIM.pm

filter: Statementstmt 95.9% 47 / 49 Branchbran 68.1% 15 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 13 / 13 Podpod 0.0% 0 / 6 totaltotal 83.3% 75 / 90 CC 18 SCAR 12.2
CC
18
Cov
87%
new
6.4
result
4.0
is_valid
3.3
CRAP 3.4
« lib/Mail/DMARC/Report/Aggregate/Record/Row/Policy_Evaluated.pm ↑ Summary lib/Mail/DMARC/Result/Reason.pm »
1 package Mail::DMARC::Report::Aggregate::Record::Auth_Results::DKIM;
2 17 our $VERSION = '2.20261110';
3 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use feature 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 17 ▶no warnings 'experimental::args_array_with_signatures'; ## no critic (ProhibitNoWarnings)
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 17 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 96 ▶sub new( $class, @args ) {
Subroutine new: called CC=6 SCAR=18.6
Pod undocumented
11  
12 96 ▶ croak "missing arguments" if !@args;
Branch: 1 branch
BranchTrueFalseTotal
unless @args 0 96 96
13  
14 96 my $self = bless {}, $class;
15  
16 # a bare hash
17 96 ▶ return $self->_from_hash(@args) if @args > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @args > 1 7 89 96
18  
19 89 my $dkim = shift @args;
20 89 ▶ croak "dkim argument not a ref" if !ref $dkim;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $dkim 0 89 89
21  
22 89 ▶ return $dkim if ref $dkim eq $class; # been here before...
Branch: 1 branch
BranchTrueFalseTotal
if ref $dkim eq $class 12 77 89
23  
24 77 ▶ return $self->_from_hashref($dkim) if 'HASH' eq ref $dkim;
Branch: 1 branch
BranchTrueFalseTotal
if "HASH" eq ref $dkim 77 0 77
25  
26 0 croak "invalid dkim argument";
27 }
28  
29 82 ▶sub domain( $self, $value = undef ) {
Subroutine domain: called CC=3 SCAR=11.2
Pod undocumented
30 82 ▶ return $self->{domain} if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 0 82 82
31 82 return $self->{domain} = $value;
32 }
33  
34 75 ▶sub selector( $self, $value = undef ) {
Subroutine selector: called CC=3 SCAR=11.2
Pod undocumented
35 75 ▶ return $self->{selector} if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 0 75 75
36 75 return $self->{selector} = $value;
37 }
38  
39 83 ▶sub result( $self, $value = undef ) {
Subroutine result: called CC=4 SCAR=13.9
Pod undocumented
40 83 ▶ return $self->{result} if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 0 83 83
41 croak "invalid DKIM result"
42 83 ▶ if !grep { $_ eq $value }
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $value;} "pass", "fail", "neutral", "none", "permerror", "policy", "temperror" 1 82 83
43 qw/ pass fail neutral none permerror policy temperror /;
44 82 return $self->{result} = $value;
45 }
46  
47 57 ▶sub human_result( $self, $value = undef ) {
Subroutine human_result: called CC=3 SCAR=11.0
Pod undocumented
48 57 ▶ return $self->{human_result} if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 2 55 57
49 55 return $self->{human_result} = $value;
50 }
51  
52 84 ▶sub _from_hash( $self, %args ) {
Subroutine _from_hash: called CC=2 SCAR=6.9
53  
54 83 foreach my $key ( keys %args ) {
55 293 $self->$key( $args{$key} );
56 }
57  
58 82 $self->is_valid;
59 82 return $self;
60 }
61  
62 77 ▶sub _from_hashref( $self, $dkim ) {
Subroutine _from_hashref: called CC=1 SCAR=0.0
63 77 return $self->_from_hash( %{$dkim} );
64 }
65  
66 82 ▶sub is_valid($self) {
Subroutine is_valid: called CC=3 SCAR=12.0
Pod undocumented
67  
68 82 foreach my $f (qw/ domain result /) {
69 164 ▶ if ( !defined $self->{$f} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{$f}) 0 164 164
70 0 croak "DKIM value $f is required!";
71 }
72 }
73 82 return;
74 }
75  
76 17 1;
77  
78 __END__
« lib/Mail/DMARC/Report/Aggregate/Record/Row/Policy_Evaluated.pm ↑ Summary lib/Mail/DMARC/Result/Reason.pm »