BIMI/Result.pm

filter: Statementstmt 84.7% 39 / 46 Branchbran 43.7% 7 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 5 / 5 totaltotal 79.4% 62 / 78 CC 9 SCAR 21.5
CC
9
Cov
74%
get_authentication_results_object
18.7
set_result
2.0
BEGIN
1.0
CRAP 8.6
« BIMI/Role/Cacheable.pm ↑ Summary BIMI/Role/HasHTTPClient.pm »
1 package Mail::BIMI::Result;
2 # ABSTRACT: Class to model a BIMI result
3 29 our $VERSION = '3.20261116'; # VERSION
4 29 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 29 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 29 ▶use Mail::BIMI::Prelude;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 29 ▶use Mail::AuthenticationResults::Header::Entry;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 29 ▶use Mail::AuthenticationResults::Header::SubEntry;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 29 ▶use Mail::AuthenticationResults::Header::Comment;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 29 extends 'Mail::BIMI::Base';
12 29 has result => ( is => 'rw', isa => 'Str',
13 documentation => 'Text result' );
14 29 has comment => ( is => 'rw', isa => 'Str',
15 documentation => 'Text comment' );
16 29 has error => ( is => 'rw',
17 documentation => 'Optional Mail::BIMI::Error object detailing failure' );
18 29 has headers => ( is => 'rw', isa => 'HashRef',
19 documentation => 'Hashref of headers to add to message' );
20  
21  
22  
23 5 ▶sub domain($self) {
Subroutine domain: called CC=1 SCAR=0.0
Pod documented
24 5 return $self->bimi_object->domain;
25 }
26  
27  
28 5 ▶sub selector($self) {
Subroutine selector: called CC=1 SCAR=0.0
Pod documented
29 5 return $self->bimi_object->selector;
30 }
31  
32  
33 14 ▶sub set_result($self,$result) {
Subroutine set_result: called CC=2 SCAR=6.9
Pod documented
34 14 ▶ if ( ref $result eq 'Mail::BIMI::Error' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $result eq 'Mail::BIMI::Error') { } 10 4 14
35 10 $self->result($result->result);
36 10 $self->comment($result->description);
37 }
38 else {
39 4 $self->result($result);
40 }
41 }
42  
43  
44 14 ▶sub get_authentication_results_object($self) {
Subroutine get_authentication_results_object: called CC=8 SCAR=29.3
Pod documented
45 14 my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'bimi' )->safe_set_value( $self->result );
46 14 ▶ if ( $self->comment ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->comment) 10 4 14
47 10 $header->add_child( Mail::AuthenticationResults::Header::Comment->new()->safe_set_value( $self->comment ) );
48 }
49 14 ▶ if ( $self->result eq 'pass' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->result eq "pass") 4 10 14
50 4 $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'header.d' )->safe_set_value( $self->bimi_object->record->retrieved_domain ) );
51 4 $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'header.selector' )->safe_set_value( $self->bimi_object->record->retrieved_selector ) );
52 }
53 14 ▶ if ( $self->bimi_object->record->authority->is_relevant ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->bimi_object->record->authority->is_relevant) 0 14 14
54 0 my $vmc = $self->bimi_object->record->authority->vmc;
55 0 ▶ if ( $vmc ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vmc) { } 0 0 0
56 0 ▶ $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.authority' )->safe_set_value( $vmc->is_valid ? 'pass' : 'fail' ) );
Branch: 1 branch
BranchTrueFalseTotal
$vmc->is_valid ? : 0 0 0
57 0 ▶ $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.experimental' )->safe_set_value('yes') )
Branch: 1 branch
BranchTrueFalseTotal
if $vmc->is_experimental 0 0 0
58 if $vmc->is_experimental;
59 0 ▶ $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.mark-type' )->safe_set_value($vmc->mark_type) )
Branch: 1 branch
BranchTrueFalseTotal
if $vmc->mark_type 0 0 0
60 if $vmc->mark_type;
61 }
62 else {
63 0 $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.authority' )->safe_set_value( 'fail' ) );
64 }
65 0 $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.authority-uri' )->safe_set_value( $self->bimi_object->record->authority->uri ) );
66 }
67  
68 14 return $header;
69 }
70  
71  
72 14 ▶sub get_authentication_results($self) {
Subroutine get_authentication_results: called CC=1 SCAR=0.0
Pod documented
73 14 return $self->get_authentication_results_object->as_string;
74 }
75  
76 29 1;
77  
78 __END__
« BIMI/Role/Cacheable.pm ↑ Summary BIMI/Role/HasHTTPClient.pm »