lib/Mail/AuthenticationResults/Header/Base.pm

filter: Statementstmt 98.3% 240 / 241 Branchbran 92.9% 128 / 142 Conditioncond 80.0% 24 / 30 MC/DCmcdc 64.7% 11 / 17 Subroutinesub 96.9% 32 / 33 Podpod 100% 20 / 20 totaltotal 94.4% 455 / 483 SCAR 45.1
CC
90
Cov
95%
search
39.0
remove_child
8.1
build_string
8.0
CRAP 90.9
« blib/lib/Mail/AuthenticationResults/Header/Comment.pm ↑ Summary blib/lib/Mail/AuthenticationResults/Header/Version.pm »
1 package Mail::AuthenticationResults::Header::Base;
2 # ABSTRACT: Base class for modelling parts of the Authentication Results Header
3  
4 29 require 5.008;
5 29 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 29 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 29 our $VERSION = '2.20230112'; # VERSION
8 29 ▶use Scalar::Util qw{ weaken refaddr };
Subroutine BEGIN: called CC=1 SCAR=0.0
9 29 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 29 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 29 ▶use Clone qw{ clone };
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 29 ▶use Mail::AuthenticationResults::Header::Group;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 29 ▶use Mail::AuthenticationResults::FoldableHeader;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16  
17 254 ▶sub _HAS_KEY{ return 0; }
Subroutine _HAS_KEY: called CC=1 SCAR=0.0
18 34 ▶sub _HAS_VALUE{ return 0; }
Subroutine _HAS_VALUE: called CC=1 SCAR=0.0
19 277 ▶sub _HAS_CHILDREN{ return 0; }
Subroutine _HAS_CHILDREN: called CC=1 SCAR=0.0
20 sub _ALLOWED_CHILDREN{ # uncoverable subroutine
21 # does not run in Base as HAS_CHILDREN returns 0
22 0 ▶ return 0; # uncoverable statement
Subroutine _ALLOWED_CHILDREN: not called CC=1 SCAR=0.0
23 }
24  
25  
26 sub new {
27 1905 ▶ my ( $class ) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
28 1905 my $self = {};
29 1905 bless $self, $class;
30 1905 return $self;
31 }
32  
33  
34 sub set_key {
35 383 ▶ my ( $self, $key ) = @_;
Subroutine set_key: called CC=7 SCAR=19.5
Pod documented
36 383 ▶ croak 'Does not have key' if ! $self->_HAS_KEY();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_HAS_KEY 4 379 383
37 379 ▶ croak 'Key cannot be undefined' if ! defined $key;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $key 2 377 379
38 377 ▶ croak 'Key cannot be empty' if $key eq q{};
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "" 2 375 377
39 375 ▶ croak 'Invalid characters in key' if $key =~ /"/;
Branch: 1 branch
BranchTrueFalseTotal
if $key =~ /"/ 2 373 375
40 373 ▶ croak 'Invalid characters in key' if $key =~ /\n/;
Branch: 1 branch
BranchTrueFalseTotal
if $key =~ /\n/ 2 371 373
41 371 ▶ croak 'Invalid characters in key' if $key =~ /\r/;
Branch: 1 branch
BranchTrueFalseTotal
if $key =~ /\r/ 2 369 371
42 369 $self->{ 'key' } = $key;
43 369 return $self;
44 }
45  
46  
47 sub key {
48 1186 ▶ my ( $self ) = @_;
Subroutine key: called CC=3 SCAR=11.0
Pod documented
49 1186 ▶ croak 'Does not have key' if ! $self->_HAS_KEY();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_HAS_KEY 6 1180 1186
50 1180 ▶ return q{} if ! defined $self->{ 'key' }; #5.8
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"key"} 4 1176 1180
51 1176 return $self->{ 'key' };
52 }
53  
54  
55 sub safe_set_value {
56 35 ▶ my ( $self, $value ) = @_;
Subroutine safe_set_value: called CC=2 SCAR=6.9
Pod documented
57  
58 35 ▶ $value = q{} if ! defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 3 32 35
59  
60 35 $value =~ s/\t/ /g;
61 35 $value =~ s/\n/ /g;
62 35 $value =~ s/\r/ /g;
63 35 $value =~ s/\(/ /g;
64 35 $value =~ s/\)/ /g;
65 35 $value =~ s/\\/ /g;
66 35 $value =~ s/"/ /g;
67 35 $value =~ s/;/ /g;
68 35 $value =~ s/^\s+//;
69 35 $value =~ s/\s+$//;
70  
71 #$value =~ s/ /_/g;
72  
73 35 $self->set_value( $value );
74 35 return $self;
75 }
76  
77  
78 sub set_value {
79 378 ▶ my ( $self, $value ) = @_;
Subroutine set_value: called CC=6 SCAR=17.9
Pod documented
80 378 ▶ croak 'Does not have value' if ! $self->_HAS_VALUE();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_HAS_VALUE 4 374 378
81 374 ▶ croak 'Value cannot be undefined' if ! defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 3 371 374
82 #croak 'Value cannot be empty' if $value eq q{};
83 371 ▶ croak 'Invalid characters in value' if $value =~ /"/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /"/ 3 368 371
84 368 ▶ croak 'Invalid characters in value' if $value =~ /\n/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /\n/ 3 365 368
85 365 ▶ croak 'Invalid characters in value' if $value =~ /\r/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /\r/ 3 362 365
86 362 $self->{ 'value' } = $value;
87 362 return $self;
88 }
89  
90  
91 sub value {
92 1510 ▶ my ( $self ) = @_;
Subroutine value: called CC=3 SCAR=11.0
Pod documented
93 1510 ▶ croak 'Does not have value' if ! $self->_HAS_VALUE();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_HAS_VALUE 1 1509 1510
94 1509 ▶ return q{} if ! defined $self->{ 'value' }; # 5.8
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"value"} 54 1455 1509
95 1455 return $self->{ 'value' };
96 }
97  
98  
99 sub stringify {
100 499 ▶ my ( $self, $value ) = @_;
Subroutine stringify: called CC=3 SCAR=11.0
Pod documented
101 499 my $string = $value;
102 499 ▶ $string = q{} if ! defined $string; #5.8;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $string 7 492 499
103  
104 499 ▶ if ( $string =~ /[\s\t \(\);=]/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /[\s\t \(\);=]/) 34 465 499
105 34 $string = '"' . $string . '"';
106 }
107  
108 499 return $string;
109 }
110  
111  
112 sub children {
113 3202 ▶ my ( $self ) = @_;
Subroutine children: called CC=3 SCAR=11.0
Pod documented
114 3202 ▶ croak 'Does not have children' if ! $self->_HAS_CHILDREN();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_HAS_CHILDREN 2 3200 3202
115 3200 ▶ return [] if ! defined $self->{ 'children' }; #5.8
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"children"} 1943 1257 3200
116 1257 return $self->{ 'children' };
117 }
118  
119  
120 sub orphan {
121 19 ▶ my ( $self, $parent ) = @_;
Subroutine orphan: called CC=2 SCAR=6.9
Pod documented
122 19 ▶ croak 'Child does not have a parent' if ! exists $self->{ 'parent' };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"parent"} 8 11 19
123 11 delete $self->{ 'parent' };
124 11 return;
125 }
126  
127  
128 sub copy_children_from {
129 1 ▶ my ( $self, $object ) = @_;
Subroutine copy_children_from: called CC=3 SCAR=11.0
Pod documented
130 1 for my $original_entry (@{$object->children()}) {
131 1 my $entry = clone $original_entry;
132 1 ▶ $entry->orphan if exists $entry->{ 'parent' };;
Branch: 1 branch
BranchTrueFalseTotal
if exists $entry->{"parent"} 1 0 1
133 1 $self->add_child( $entry );
134 }
135 }
136  
137  
138 sub add_parent {
139 748 ▶ my ( $self, $parent ) = @_;
Subroutine add_parent: called CC=4 SCAR=13.9
Pod documented
140 748 ▶ return if ( ref $parent eq 'Mail::AuthenticationResults::Header::Group' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $parent eq "Mail::AuthenticationResults::Header::Group" 364 384 748
141 384 ▶ croak 'Child already has a parent' if exists $self->{ 'parent' };
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"parent"} 4 380 384
142 380 ▶ croak 'Cannot add parent' if ! $parent->_ALLOWED_CHILDREN( $self ); # uncoverable branch true
Branch: 1 branch
BranchTrueFalseTotal
unless $parent->_ALLOWED_CHILDREN($self) 0 380 380
143 # Does not run as test is also done in add_child before add_parent is called.
144 380 $self->{ 'parent' } = $parent;
145 380 weaken $self->{ 'parent' };
146 380 return;
147 }
148  
149  
150 sub parent {
151 732 ▶ my ( $self ) = @_;
Subroutine parent: called CC=1 SCAR=0.0
Pod documented
152 732 return $self->{ 'parent' };
153 }
154  
155  
156 sub remove_child {
157 16 ▶ my ( $self, $child ) = @_;
Subroutine remove_child: called CC=8 SCAR=20.9
Pod documented
158 16 ▶ croak 'Does not have children' if ! $self->_HAS_CHILDREN();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_HAS_CHILDREN 0 16 16
159 16 ▶ croak 'Cannot add child' if ! $self->_ALLOWED_CHILDREN( $child );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_ALLOWED_CHILDREN($child) 0 16 16
160 16 ▶ croak 'Cannot add a class as its own parent' if refaddr $self == refaddr $child; # uncoverable branch true
Branch: 1 branch
BranchTrueFalseTotal
if builtin::refaddr($self) == builtin::refaddr($child) 0 16 16
161 # Does not run as there are no ALLOWED_CHILDREN results which permit this
162  
163 16 my @children;
164 16 my $child_removed = 0;
165 16 foreach my $mychild ( @{ $self->{ 'children' } } ) {
166 39 ▶ if ( refaddr $child == refaddr $mychild ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::refaddr($child) == builtin::refaddr($mychild)) { } 16 23 39
167 16 ▶ if ( ref $self ne 'Mail::AuthenticationResults::Header::Group' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self ne "Mail::AuthenticationResults::Header::Group") 10 6 16
168 10 $child->orphan();
169 }
170 16 $child_removed = 1;
171 }
172 else {
173 23 push @children, $mychild;
174 }
175 }
176 16 my $children = $self->{ 'children' };
177  
178 16 ▶ croak 'Not a child of this class' if ! $child_removed;
Branch: 1 branch
BranchTrueFalseTotal
unless $child_removed 0 16 16
179  
180 16 $self->{ 'children' } = \@children;
181  
182 16 return $self;
183 }
184  
185  
186 sub add_child {
187 822 ▶ my ( $self, $child ) = @_;
Subroutine add_child: called CC=4 SCAR=13.9
Pod documented
188 822 ▶ croak 'Does not have children' if ! $self->_HAS_CHILDREN();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_HAS_CHILDREN 29 793 822
189 793 ▶ croak 'Cannot add child' if ! $self->_ALLOWED_CHILDREN( $child );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_ALLOWED_CHILDREN($child) 25 768 793
190 768 ▶ croak 'Cannot add a class as its own parent' if refaddr $self == refaddr $child; # uncoverable branch true
Branch: 1 branch
BranchTrueFalseTotal
if builtin::refaddr($self) == builtin::refaddr($child) 0 768 768
191 # Does not run as there are no ALLOWED_CHILDREN results which permit this
192  
193 768 $child->add_parent( $self );
194 764 push @{ $self->{ 'children' } }, $child;
195  
196 764 return $child;
197 }
198  
199  
200 sub ancestor {
201 260 ▶ my ( $self ) = @_;
Subroutine ancestor: called CC=2 SCAR=6.9
Pod documented
202  
203 260 my $depth = 0;
204 260 my $ancestor = $self->parent();
205 260 my $eldest = $self;
206 260 ▶ while ( defined $ancestor ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ancestor) 463 260 723
207 463 $eldest = $ancestor;
208 463 $ancestor = $ancestor->parent();
209 463 $depth++;
210 }
211  
212 260 return ( $eldest, $depth );
213 }
214  
215  
216 sub as_string_prefix {
217 260 ▶ my ( $self, $header ) = @_;
Subroutine as_string_prefix: called CC=6 SCAR=18.0
Pod documented
218  
219 260 my ( $eldest, $depth ) = $self->ancestor();
220  
221 260 my $indents = 1;
222 260 ▶ if ( $eldest->can( 'indent_by' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($eldest->can("indent_by")) 260 0 260
223 260 $indents = $eldest->indent_by();
224 }
225  
226 260 my $eol = "\n";
227 260 ▶ if ( $eldest->can( 'eol' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($eldest->can("eol")) 260 0 260
228 260 $eol = $eldest->eol();
229 }
230  
231 260 my $indent = ' ';
232 260 my $added = 0;
233 260 ▶ if ( $eldest->can( 'indent_on' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($eldest->can("indent_on")) 260 0 260
234 260 ▶ if ( $eldest->indent_on( ref $self ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($eldest->indent_on(ref $self)) 89 171 260
235 89 $header->space( $eol );
236 89 $header->space( ' ' x ( $indents * $depth ) );
237 89 $added = 1;
238 }
239 }
240 260 ▶ $header->space( ' ' ) if ! $added;
Branch: 1 branch
BranchTrueFalseTotal
unless $added 171 89 260
241  
242 260 return $indent;
243 }
244  
245 sub _as_hashref {
246 46 ▶ my ( $self ) = @_;
Subroutine _as_hashref: called CC=4 SCAR=13.9
247  
248 46 my $type = lc ref $self;
249 46 $type =~ s/^(.*::)//;
250 46 my $hashref = { 'type' => $type };
251  
252 46 ▶ $hashref->{'key'} = $self->key() if $self->_HAS_KEY();
Branch: 1 branch
BranchTrueFalseTotal
if $self->_HAS_KEY 32 14 46
253 46 ▶ $hashref->{'value'} = $self->value() if $self->_HAS_VALUE();
Branch: 1 branch
BranchTrueFalseTotal
if $self->_HAS_VALUE 46 0 46
254 46 ▶ if ( $self->_HAS_CHILDREN() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_HAS_CHILDREN) 34 12 46
255 34 my @children = map { $_->_as_hashref() } @{ $self->children() };
256 34 $hashref->{'children'} = \@children;
257 }
258 46 return $hashref;
259 }
260  
261  
262 sub as_json {
263 2 ▶ my ( $self ) = @_;
Subroutine as_json: called CC=1 SCAR=0.0
Pod documented
264 2 my $J = JSON->new();
265 2 $J->canonical();
266 2 return $J->encode( $self->_as_hashref() );
267 }
268  
269  
270 sub as_string {
271 74 ▶ my ( $self ) = @_;
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
272 74 my $header = Mail::AuthenticationResults::FoldableHeader->new();
273 74 $self->build_string( $header );
274 74 return $header->as_string();
275 }
276  
277  
278 sub build_string {
279 237 ▶ my ( $self, $header ) = @_;
Subroutine build_string: called CC=8 SCAR=20.8
Pod documented
280  
281 237 ▶ if ( ! $self->key() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->key) 2 235 237
282 2 return;
283 }
284  
285 235 $header->string( $self->stringify( $self->key() ) );
286 235 ▶ if ( $self->value() ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->value) { } 214 21 235
elsif ($self->value eq '0') { } 2 19 21
elsif ($self->value eq '') { } 19 0 19
287 214 $header->assignment( '=' );
288 214 $header->string( $self->stringify( $self->value() ) );
289 }
290 elsif ( $self->value() eq '0' ) {
291 2 $header->assignment( '=' );
292 2 $header->string( '0' );
293 }
294 elsif ( $self->value() eq q{} ) {
295 # special case none here
296 19 ▶ if ( $self->key() ne 'none' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->key ne "none") 17 2 19
297 17 $header->assignment( '=' );
298 17 $header->string( '""' );
299 }
300 }
301 235 ▶ if ( $self->_HAS_CHILDREN() ) { # uncoverable branch false
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_HAS_CHILDREN) 235 0 235
302 # There are no classes which run this code without having children
303 235 foreach my $child ( @{$self->children()} ) {
304 181 $child->as_string_prefix( $header );
305 181 $child->build_string( $header );
306 }
307 }
308 235 return;
309 }
310  
311  
312 sub search {
313 1238 ▶ my ( $self, $search ) = @_;
Subroutine search: called CC=38 SCAR=36.6
Pod documented
314  
315 1238 my $group = Mail::AuthenticationResults::Header::Group->new();
316  
317 1238 my $match = 1;
318  
319 1238 ▶ if ( exists( $search->{ 'key' } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $search->{"key"}) 792 446 1238
320 792 ▶ if ( $self->_HAS_KEY() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_HAS_KEY) { } 574 218 792
321 574 ▶ if ( ref $search->{ 'key' } eq 'Regexp' && $self->key() =~ m/$search->{'key'}/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $search->{'key'} eq 'Regexp' and $self->key =~ /$search->{'key'}/) { } 1 573 574
elsif (lc $search->{'key'} eq lc $self->key) { } 84 489 573
Condition100%3/3
ref $search->{"key"} eq "Regexp" and $self->key =~ /$search->{"key"}/
!ll&&!rl&&r
57121
MC/DC100%2/2
ref $search->{"key"} eq "Regexp" and $self->key =~ /$search->{"key"}/
ref $search->{"key"} eq "Regexp" $self->key =~ /$search->{"key"}/
Truth table100%3/3
A and B
A= ref $search->{"key"} eq "Regexp"B= $self->key =~ /$search->{"key"}/
ABresult
0X0
100
111
322 1 ▶ $match = $match && 1; # uncoverable statement
Condition50%1/2
$match && 1
!ll
01
MC/DC0%0/1
$match && 1
$match
Truth table50%1/2
A
A= $match
Aresult
00
11
323 # $match is always 1 at this point, left this way for consistency
324 }
325 elsif ( lc $search->{ 'key' } eq lc $self->key() ) {
326 84 ▶ $match = $match && 1; # uncoverable statement
Condition50%1/2
$match && 1
!ll
084
MC/DC0%0/1
$match && 1
$match
Truth table50%1/2
A
A= $match
Aresult
00
11
327 # $match is always 1 at this point, left this way for consistency
328 }
329 else {
330 489 $match = 0;
331 }
332 }
333 else {
334 218 $match = 0;
335 }
336 }
337  
338 1238 ▶ if ( exists( $search->{ 'value' } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $search->{"value"}) 694 544 1238
339 694 ▶ $search->{ 'value' } = '' if ! defined $search->{ 'value' };
Branch: 1 branch
BranchTrueFalseTotal
unless defined $search->{"value"} 0 694 694
340 694 ▶ if ( $self->_HAS_VALUE() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_HAS_VALUE) { } 675 19 694
341 675 ▶ if ( ref $search->{ 'value' } eq 'Regexp' && $self->value() =~ m/$search->{'value'}/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $search->{'value'} eq 'Regexp' and $self->value =~ /$search->{'value'}/) { } 1 674 675
elsif (lc $search->{'value'} eq lc $self->value) { } 156 518 674
Condition100%3/3
ref $search->{"value"} eq "Regexp" and $self->value =~ /$search->{"value"}/
!ll&&!rl&&r
67041
MC/DC100%2/2
ref $search->{"value"} eq "Regexp" and $self->value =~ /$search->{"value"}/
ref $search->{"value"} eq "Regexp" $self->value =~ /$search->{"value"}/
Truth table100%3/3
A and B
A= ref $search->{"value"} eq "Regexp"B= $self->value =~ /$search->{"value"}/
ABresult
0X0
100
111
342 1 ▶ $match = $match && 1;
Condition50%1/2
$match && 1
!ll
01
MC/DC0%0/1
$match && 1
$match
Truth table50%1/2
A
A= $match
Aresult
00
11
343 }
344 elsif ( lc $search->{ 'value' } eq lc $self->value() ) {
345 156 ▶ $match = $match && 1;
Condition100%2/2
$match && 1
!ll
9759
MC/DC100%1/1
$match && 1
$match
Truth table100%2/2
A
A= $match
Aresult
00
11
346 }
347 else {
348 518 $match = 0;
349 }
350 }
351 else {
352 19 $match = 0; # uncoverable statement
353 # There are no code paths with the current classes which end up here
354 }
355 }
356  
357 1238 ▶ if ( exists( $search->{ 'authserv_id' } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $search->{"authserv_id"}) 87 1151 1238
358 87 ▶ if ( $self->_HAS_VALUE() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_HAS_VALUE) { } 82 5 87
359 82 ▶ if ( lc ref $self eq 'mail::authenticationresults::header' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc ref $self eq 'mail::authenticationresults::header') { } 16 66 82
360 16 ▶ my $authserv_id = eval{ $self->value()->value() } || q{};
Condition50%1/2
eval { do { $self->value->value } } || ''
l!l
160
MC/DC0%0/1
eval { do { $self->value->value } } || ''
eval { do { $self->value->value } }
Truth table50%1/2
A
A= eval { do { $self->value->value } }
Aresult
11
00
361 16 ▶ if ( ref $search->{ 'authserv_id' } eq 'Regexp' && $authserv_id =~ m/$search->{'authserv_id'}/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $search->{'authserv_id'} eq 'Regexp' and $authserv_id =~ /$search->{'authserv_id'}/) { } 2 14 16
elsif (lc $search->{'authserv_id'} eq lc $authserv_id) { } 3 11 14
Condition100%3/3
ref $search->{"authserv_id"} eq "Regexp" and $authserv_id =~ /$search->{"authserv_id"}/
!ll&&!rl&&r
1222
MC/DC100%2/2
ref $search->{"authserv_id"} eq "Regexp" and $authserv_id =~ /$search->{"authserv_id"}/
ref $search->{"authserv_id"} eq "Regexp" $authserv_id =~ /$search->{"authserv_id"}/
Truth table100%3/3
A and B
A= ref $search->{"authserv_id"} eq "Regexp"B= $authserv_id =~ /$search->{"authserv_id"}/
ABresult
0X0
100
111
362 2 ▶ $match = $match && 1;
Condition50%1/2
$match && 1
!ll
02
MC/DC0%0/1
$match && 1
$match
Truth table50%1/2
A
A= $match
Aresult
00
11
363 }
364 elsif ( lc $search->{ 'authserv_id' } eq lc $authserv_id ) {
365 3 ▶ $match = $match && 1;
Condition50%1/2
$match && 1
!ll
03
MC/DC0%0/1
$match && 1
$match
Truth table50%1/2
A
A= $match
Aresult
00
11
366 }
367 else {
368 11 $match = 0;
369 }
370 }
371 else {
372 66 $match = 0;
373 }
374 }
375 else {
376 5 $match = 0; # uncoverable statement
377 # There are no code paths with the current classes which end up here
378 }
379 }
380  
381 1238 ▶ if ( exists( $search->{ 'isa' } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $search->{"isa"}) 412 826 1238
382 412 ▶ if ( lc ref $self eq 'mail::authenticationresults::header::' . lc $search->{ 'isa' } ) {
Branch: 2 branches
BranchTrueFalseTotal
if (lc ref $self eq 'mail::authenticationresults::header::' . lc($search->{'isa'})) { } 119 293 412
elsif (lc ref $self eq 'mail::authenticationresults::header' and lc $search->{'isa'} eq 'header') { } 5 288 293
383 119 ▶ $match = $match && 1;
Condition100%2/2
$match && 1
!ll
2198
MC/DC100%1/1
$match && 1
$match
Truth table100%2/2
A
A= $match
Aresult
00
11
384 }
385 ▶ elsif ( lc ref $self eq 'mail::authenticationresults::header' && lc $search->{ 'isa' } eq 'header' ) {
Condition100%3/3
lc ref $self eq "mail::authenticationresults::header" and lc $search->{"isa"} eq "header"
!ll&&!rl&&r
242465
MC/DC100%2/2
lc ref $self eq "mail::authenticationresults::header" and lc $search->{"isa"} eq "header"
lc ref $self eq "mail::authenticationresults::header" lc $search->{"isa"} eq "header"
Truth table100%3/3
A and B
A= lc ref $self eq "mail::authenticationresults::header"B= lc $search->{"isa"} eq "header"
ABresult
0X0
100
111
386 5 ▶ $match = $match && 1;
Condition100%2/2
$match && 1
!ll
32
MC/DC100%1/1
$match && 1
$match
Truth table100%2/2
A
A= $match
Aresult
00
11
387 }
388 else {
389 288 $match = 0;
390 }
391 }
392  
393 1238 ▶ if ( exists( $search->{ 'has' } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $search->{"has"}) 33 1205 1238
394 33 foreach my $query ( @{ $search->{ 'has' } } ) {
395 38 ▶ $match = 0 if ( scalar @{ $self->search( $query )->children() } == 0 );
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$self->search($query)->children;} == 0 23 15 38
396 }
397 }
398  
399 1238 ▶ if ( $match ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($match) 170 1068 1238
400 170 $group->add_child( $self );
401 }
402  
403 1238 ▶ if ( $self->_HAS_CHILDREN() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_HAS_CHILDREN) 1004 234 1238
404 1004 foreach my $child ( @{$self->children()} ) {
405 1088 my $childfound = $child->search( $search );
406 1088 ▶ if ( scalar @{ $childfound->children() } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$childfound->children;}) 199 889 1088
407 199 $group->add_child( $childfound );
408 }
409 }
410 }
411  
412 1238 return $group;
413 }
414  
415 29 1;
416  
417 __END__
« blib/lib/Mail/AuthenticationResults/Header/Comment.pm ↑ Summary blib/lib/Mail/AuthenticationResults/Header/Version.pm »