lib/Mail/AuthenticationResults/Header/Base.pm

filter: Statementstmt 98.5% 270 / 271 (5 uncoverable) Branchbran 92.5% 133 / 148 (4 uncoverable) Conditioncond 84.6% 33 / 39 MC/DCmcdc 66.6% 14 / 21 Subroutinesub 100% 40 / 41 (1 uncoverable) Podpod 100% 25 / 25 totaltotal 94.8% 515 / 545 (10 uncoverable) CC 96 SCAR 26.4
CC
96
Cov
95%
search
39.0
remove_child
8.1
build_string
8.0
CRAP 14.0
« blib/lib/Mail/AuthenticationResults/Header.pm ↑ Summary lib/Mail/AuthenticationResults/Parser.pm »
1 package Mail::AuthenticationResults::Header::Base;
2 # ABSTRACT: Base class for modelling parts of the Authentication Results Header
3  
4 30 require 5.008;
5 30 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 30 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 30 our $VERSION = '2.20260216'; # VERSION
8 30 ▶use Scalar::Util qw{ weaken refaddr };
Subroutine BEGIN: called CC=1 SCAR=0.0
9 30 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 30 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 30 ▶use Clone qw{ clone };
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 30 ▶use Mail::AuthenticationResults::Header::Group;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 30 ▶use Mail::AuthenticationResults::FoldableHeader;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 30 ▶use Mail::AuthenticationResults::Header::Entry;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 30 ▶use Mail::AuthenticationResults::Header::SubEntry;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 30 ▶use Mail::AuthenticationResults::Header::Comment;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21  
22 254 ▶sub _HAS_KEY{ return 0; }
Subroutine _HAS_KEY: called CC=1 SCAR=0.0
23 34 ▶sub _HAS_VALUE{ return 0; }
Subroutine _HAS_VALUE: called CC=1 SCAR=0.0
24 285 ▶sub _HAS_CHILDREN{ return 0; }
Subroutine _HAS_CHILDREN: called CC=1 SCAR=0.0
25 0 ▶sub _ALLOWED_CHILDREN{ # uncoverable subroutine
Subroutine _ALLOWED_CHILDREN: not called (uncoverable) CC=1 SCAR=0.0
26 # does not run in Base as HAS_CHILDREN returns 0
27 0 return 0; # uncoverable statement
28 }
29  
30  
31 1950 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
32 1950 my ( $class ) = @_;
33 1950 my $self = {};
34 1950 bless $self, $class;
35 1950 return $self;
36 }
37  
38  
39 389 ▶sub set_key {
Subroutine set_key: called CC=7 SCAR=19.5
Pod documented
40 389 my ( $self, $key ) = @_;
41 389 ▶ croak 'Does not have key' if ! $self->_HAS_KEY();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_HAS_KEY 4 385 389
42 385 ▶ croak 'Key cannot be undefined' if ! defined $key;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $key 2 383 385
43 383 ▶ croak 'Key cannot be empty' if $key eq q{};
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "" 2 381 383
44 381 ▶ croak 'Invalid characters in key' if $key =~ /"/;
Branch: 1 branch
BranchTrueFalseTotal
if $key =~ /"/ 2 379 381
45 379 ▶ croak 'Invalid characters in key' if $key =~ /\n/;
Branch: 1 branch
BranchTrueFalseTotal
if $key =~ /\n/ 2 377 379
46 377 ▶ croak 'Invalid characters in key' if $key =~ /\r/;
Branch: 1 branch
BranchTrueFalseTotal
if $key =~ /\r/ 2 375 377
47 375 $self->{ 'key' } = $key;
48 375 return $self;
49 }
50  
51  
52 1239 ▶sub key {
Subroutine key: called CC=3 SCAR=11.0
Pod documented
53 1239 my ( $self ) = @_;
54 1239 ▶ croak 'Does not have key' if ! $self->_HAS_KEY();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_HAS_KEY 6 1233 1239
55 1233 ▶ return q{} if ! defined $self->{ 'key' }; #5.8
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"key"} 4 1229 1233
56 1229 return $self->{ 'key' };
57 }
58  
59  
60 39 ▶sub safe_set_value {
Subroutine safe_set_value: called CC=2 SCAR=6.9
Pod documented
61 39 my ( $self, $value ) = @_;
62  
63 39 ▶ $value = q{} if ! defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 3 36 39
64  
65 39 $value =~ s/\t/ /g;
66 39 $value =~ s/\n/ /g;
67 39 $value =~ s/\r/ /g;
68 39 $value =~ s/\(/ /g;
69 39 $value =~ s/\)/ /g;
70 39 $value =~ s/\\/ /g;
71 39 $value =~ s/"/ /g;
72 39 $value =~ s/;/ /g;
73 39 $value =~ s/^\s+//;
74 39 $value =~ s/\s+$//;
75  
76 #$value =~ s/ /_/g;
77  
78 39 $self->set_value( $value );
79 39 return $self;
80 }
81  
82  
83 385 ▶sub set_value {
Subroutine set_value: called CC=6 SCAR=17.9
Pod documented
84 385 my ( $self, $value ) = @_;
85 385 ▶ croak 'Does not have value' if ! $self->_HAS_VALUE();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_HAS_VALUE 4 381 385
86 381 ▶ croak 'Value cannot be undefined' if ! defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 3 378 381
87 #croak 'Value cannot be empty' if $value eq q{};
88 378 ▶ croak 'Invalid characters in value' if $value =~ /"/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /"/ 3 375 378
89 375 ▶ croak 'Invalid characters in value' if $value =~ /\n/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /\n/ 3 372 375
90 372 ▶ croak 'Invalid characters in value' if $value =~ /\r/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /\r/ 3 369 372
91 369 $self->{ 'value' } = $value;
92 369 return $self;
93 }
94  
95  
96 1577 ▶sub value {
Subroutine value: called CC=3 SCAR=11.0
Pod documented
97 1577 my ( $self ) = @_;
98 1577 ▶ croak 'Does not have value' if ! $self->_HAS_VALUE();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_HAS_VALUE 1 1576 1577
99 1576 ▶ return q{} if ! defined $self->{ 'value' }; # 5.8
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"value"} 59 1517 1576
100 1517 return $self->{ 'value' };
101 }
102  
103  
104 551 ▶sub stringify {
Subroutine stringify: called CC=6 SCAR=17.9
Pod documented
105 551 my ( $self, $value ) = @_;
106 551 my $string = $value;
107 551 ▶ $string = q{} if ! defined $string; #5.8;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $string 7 544 551
108 551 my $strict_quotes = $self->strict_quotes;
109  
110 551 ▶ if ( ( $strict_quotes && $string =~ /[\s\t \(\);=<>@,:\\\/\[\]\?]/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($strict_quotes and $string =~ m<[\s\t \(\);=<>\@,:\\/\[\]\?]> or not $strict_quotes and $string =~ /[\s\t \(\);=]/) 37 514 551
Condition100%9/9
$strict_quotes and $string =~ m<[\s\t \(\);=<>\@,:\\/\[\]\?]> or not $strict_quotes and $string =~ /[\s\t \(\);=]/
l!l&&r!l&&!r
334514
$strict_quotes and $string =~ m<[\s\t \(\);=<>\@,:\\/\[\]\?]>
!ll&&!rl&&r
516323
not $strict_quotes and $string =~ /[\s\t \(\);=]/
!ll&&!rl&&r
3248234
MC/DC75%3/4
$strict_quotes and $string =~ m<[\s\t \(\);=<>\@,:\\/\[\]\?]> or not $strict_quotes and $string =~ /[\s\t \(\);=]/
$strict_quotes $string =~ m<[\s\t \(\);=<>\@,:\\/\[\]\?]> not $strict_quotes $string =~ /[\s\t \(\);=]/
Truth table57%4/7
A and B or not(C) and D
A= $strict_quotesB= $string =~ m<[\s\t \(\);=<>\@,:\\/\[\]\?]>C= not $strict_quotesD= $string =~ /[\s\t \(\);=]/
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
111 || ( !$strict_quotes && $string =~ /[\s\t \(\);=]/ ) ) {
112 37 $string = '"' . $string . '"';
113 }
114  
115 551 return $string;
116 }
117  
118  
119 3345 ▶sub children {
Subroutine children: called CC=3 SCAR=11.0
Pod documented
120 3345 my ( $self ) = @_;
121 3345 ▶ croak 'Does not have children' if ! $self->_HAS_CHILDREN();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_HAS_CHILDREN 2 3343 3345
122 3343 ▶ return [] if ! defined $self->{ 'children' }; #5.8
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"children"} 2007 1336 3343
123 1336 return $self->{ 'children' };
124 }
125  
126  
127 19 ▶sub orphan {
Subroutine orphan: called CC=2 SCAR=6.9
Pod documented
128 19 my ( $self, $parent ) = @_;
129 19 ▶ croak 'Child does not have a parent' if ! exists $self->{ 'parent' };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"parent"} 8 11 19
130 11 delete $self->{ 'parent' };
131 11 return;
132 }
133  
134  
135 1 ▶sub copy_children_from {
Subroutine copy_children_from: called CC=3 SCAR=11.0
Pod documented
136 1 my ( $self, $object ) = @_;
137 1 for my $original_entry (@{$object->children()}) {
138 1 my $entry = clone $original_entry;
139 1 ▶ $entry->orphan if exists $entry->{ 'parent' };;
Branch: 1 branch
BranchTrueFalseTotal
if exists $entry->{"parent"} 1 0 1
140 1 $self->add_child( $entry );
141 }
142 }
143  
144  
145 786 ▶sub add_parent {
Subroutine add_parent: called CC=4 SCAR=13.9
Pod documented
146 786 my ( $self, $parent ) = @_;
147 786 ▶ return if ( ref $parent eq 'Mail::AuthenticationResults::Header::Group' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $parent eq "Mail::AuthenticationResults::Header::Group" 394 392 786
148 392 ▶ croak 'Child already has a parent' if exists $self->{ 'parent' };
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"parent"} 4 388 392
149 388 ▶ croak 'Cannot add parent' if ! $parent->_ALLOWED_CHILDREN( $self ); # uncoverable branch true
Branch: 1 branch
BranchTrueFalseTotal
unless $parent->_ALLOWED_CHILDREN($self) 0 388 388
150 # Does not run as test is also done in add_child before add_parent is called.
151 388 $self->{ 'parent' } = $parent;
152 388 weaken $self->{ 'parent' };
153 388 return;
154 }
155  
156  
157 2471 ▶sub parent {
Subroutine parent: called CC=1 SCAR=0.0
Pod documented
158 2471 my ( $self ) = @_;
159 2471 return $self->{ 'parent' };
160 }
161  
162  
163 16 ▶sub remove_child {
Subroutine remove_child: called CC=8 SCAR=20.9
Pod documented
164 16 my ( $self, $child ) = @_;
165 16 ▶ croak 'Does not have children' if ! $self->_HAS_CHILDREN();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_HAS_CHILDREN 0 16 16
166 16 ▶ croak 'Cannot add child' if ! $self->_ALLOWED_CHILDREN( $child );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_ALLOWED_CHILDREN($child) 0 16 16
167 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
168 # Does not run as there are no ALLOWED_CHILDREN results which permit this
169  
170 16 my @children;
171 16 my $child_removed = 0;
172 16 foreach my $mychild ( @{ $self->{ 'children' } } ) {
173 39 ▶ if ( refaddr $child == refaddr $mychild ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::refaddr($child) == builtin::refaddr($mychild)) { } 16 23 39
174 16 ▶ if ( ref $self ne 'Mail::AuthenticationResults::Header::Group' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self ne "Mail::AuthenticationResults::Header::Group") 10 6 16
175 10 $child->orphan();
176 }
177 16 $child_removed = 1;
178 }
179 else {
180 23 push @children, $mychild;
181 }
182 }
183 16 my $children = $self->{ 'children' };
184  
185 16 ▶ croak 'Not a child of this class' if ! $child_removed;
Branch: 1 branch
BranchTrueFalseTotal
unless $child_removed 0 16 16
186  
187 16 $self->{ 'children' } = \@children;
188  
189 16 return $self;
190 }
191  
192  
193 860 ▶sub add_child {
Subroutine add_child: called CC=4 SCAR=13.9
Pod documented
194 860 my ( $self, $child ) = @_;
195 860 ▶ croak 'Does not have children' if ! $self->_HAS_CHILDREN();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_HAS_CHILDREN 29 831 860
196 831 ▶ croak 'Cannot add child' if ! $self->_ALLOWED_CHILDREN( $child );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_ALLOWED_CHILDREN($child) 25 806 831
197 806 ▶ 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 806 806
198 # Does not run as there are no ALLOWED_CHILDREN results which permit this
199  
200 806 $child->add_parent( $self );
201 802 push @{ $self->{ 'children' } }, $child;
202  
203 802 return $child;
204 }
205  
206  
207 2 ▶sub add_entry {
Subroutine add_entry: called CC=1 SCAR=0.0
Pod documented
208 2 my ($self, $key, $value) = @_;
209 2 my $child = Mail::AuthenticationResults::Header::Entry->new->set_key($key)->safe_set_value($value);
210 2 $self->add_child($child);
211 2 return $child;
212 }
213  
214  
215 2 ▶sub add_sub_entry {
Subroutine add_sub_entry: called CC=1 SCAR=0.0
Pod documented
216 2 my ($self, $key, $value) = @_;
217 2 my $child = Mail::AuthenticationResults::Header::SubEntry->new->set_key($key)->safe_set_value($value);
218 2 $self->add_child($child);
219 1 return $child;
220 }
221  
222  
223 2 ▶sub add_comment {
Subroutine add_comment: called CC=1 SCAR=0.0
Pod documented
224 2 my ($self, $value) = @_;
225 2 my $child = Mail::AuthenticationResults::Header::Comment->new->safe_set_value($value);
226 2 $self->add_child($child);
227 2 return $child;
228 }
229  
230  
231 1256 ▶sub ancestor {
Subroutine ancestor: called CC=2 SCAR=6.9
Pod documented
232 1256 my ( $self ) = @_;
233  
234 1256 my $depth = 0;
235 1256 my $ancestor = $self->parent();
236 1256 my $eldest = $self;
237 1256 ▶ while ( defined $ancestor ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ancestor) 1206 1256 2462
238 1206 $eldest = $ancestor;
239 1206 $ancestor = $ancestor->parent();
240 1206 $depth++;
241 }
242  
243 1256 return ( $eldest, $depth );
244 }
245  
246  
247 999 ▶sub strict_quotes {
Subroutine strict_quotes: called CC=3 SCAR=11.0
Pod documented
248 999 my ( $self ) = @_;
249  
250 999 ▶ return $self->{ 'strict_quotes' } if defined $self->{ 'strict_quotes' };
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"strict_quotes"} 35 964 999
251  
252 964 my ( $eldest, $depth ) = $self->ancestor();
253 964 ▶ return 0 if $depth == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $depth == 0 516 448 964
254 448 return $eldest->strict_quotes;
255 }
256  
257  
258 2 ▶sub set_strict_quotes {
Subroutine set_strict_quotes: called CC=2 SCAR=7.1
Pod documented
259 2 my ( $self, $value ) = @_;
260 2 ▶ $self->{ 'strict_quotes' } = $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 2 0 2
261 2 return $self;
262 }
263  
264  
265 292 ▶sub as_string_prefix {
Subroutine as_string_prefix: called CC=6 SCAR=18.0
Pod documented
266 292 my ( $self, $header ) = @_;
267  
268 292 my ( $eldest, $depth ) = $self->ancestor();
269  
270 292 my $indents = 1;
271 292 ▶ if ( $eldest->can( 'indent_by' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($eldest->can("indent_by")) 292 0 292
272 292 $indents = $eldest->indent_by();
273 }
274  
275 292 my $eol = "\n";
276 292 ▶ if ( $eldest->can( 'eol' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($eldest->can("eol")) 292 0 292
277 292 $eol = $eldest->eol();
278 }
279  
280 292 my $indent = ' ';
281 292 my $added = 0;
282 292 ▶ if ( $eldest->can( 'indent_on' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($eldest->can("indent_on")) 292 0 292
283 292 ▶ if ( $eldest->indent_on( ref $self ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($eldest->indent_on(ref $self)) 117 175 292
284 117 $header->space( $eol );
285 117 $header->space( ' ' x ( $indents * $depth ) );
286 117 $added = 1;
287 }
288 }
289 292 ▶ $header->space( ' ' ) if ! $added;
Branch: 1 branch
BranchTrueFalseTotal
unless $added 175 117 292
290  
291 292 return $indent;
292 }
293  
294 46 ▶sub _as_hashref {
Subroutine _as_hashref: called CC=4 SCAR=13.9
295 46 my ( $self ) = @_;
296  
297 46 my $type = lc ref $self;
298 46 $type =~ s/^(.*::)//;
299 46 my $hashref = { 'type' => $type };
300  
301 46 ▶ $hashref->{'key'} = $self->key() if $self->_HAS_KEY();
Branch: 1 branch
BranchTrueFalseTotal
if $self->_HAS_KEY 32 14 46
302 46 ▶ $hashref->{'value'} = $self->value() if $self->_HAS_VALUE();
Branch: 1 branch
BranchTrueFalseTotal
if $self->_HAS_VALUE 46 0 46
303 46 ▶ if ( $self->_HAS_CHILDREN() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_HAS_CHILDREN) 34 12 46
304 34 my @children = map { $_->_as_hashref() } @{ $self->children() };
305 34 $hashref->{'children'} = \@children;
306 }
307 46 return $hashref;
308 }
309  
310  
311 2 ▶sub as_json {
Subroutine as_json: called CC=1 SCAR=0.0
Pod documented
312 2 my ( $self ) = @_;
313 2 my $J = JSON->new();
314 2 $J->canonical();
315 2 return $J->encode( $self->_as_hashref() );
316 }
317  
318  
319 76 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
320 76 my ( $self ) = @_;
321 76 my $header = Mail::AuthenticationResults::FoldableHeader->new();
322 76 $self->build_string( $header );
323 76 return $header->as_string();
324 }
325  
326  
327 263 ▶sub build_string {
Subroutine build_string: called CC=8 SCAR=20.8
Pod documented
328 263 my ( $self, $header ) = @_;
329  
330 263 ▶ if ( ! $self->key() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->key) 2 261 263
331 2 return;
332 }
333  
334 261 $header->string( $self->stringify( $self->key() ) );
335 261 ▶ if ( $self->value() ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->value) { } 239 22 261
elsif ($self->value eq '0') { } 2 20 22
elsif ($self->value eq '') { } 20 0 20
336 239 $header->assignment( '=' );
337 239 $header->string( $self->stringify( $self->value() ) );
338 }
339 elsif ( $self->value() eq '0' ) {
340 2 $header->assignment( '=' );
341 2 $header->string( '0' );
342 }
343 elsif ( $self->value() eq q{} ) {
344 # special case none here
345 20 ▶ if ( $self->key() ne 'none' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->key ne "none") 18 2 20
346 18 $header->assignment( '=' );
347 18 $header->string( '""' );
348 }
349 }
350 261 ▶ if ( $self->_HAS_CHILDREN() ) { # uncoverable branch false
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_HAS_CHILDREN) 261 0 261
351 # There are no classes which run this code without having children
352 261 foreach my $child ( @{$self->children()} ) {
353 197 $child->as_string_prefix( $header );
354 197 $child->build_string( $header );
355 }
356 }
357 261 return;
358 }
359  
360  
361 1273 ▶sub search {
Subroutine search: called CC=38 SCAR=36.6
Pod documented
362 1273 my ( $self, $search ) = @_;
363  
364 1273 my $group = Mail::AuthenticationResults::Header::Group->new();
365  
366 1273 my $match = 1;
367  
368 1273 ▶ if ( exists( $search->{ 'key' } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $search->{"key"}) 792 481 1273
369 792 ▶ if ( $self->_HAS_KEY() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_HAS_KEY) { } 574 218 792
370 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
371 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
372 # $match is always 1 at this point, left this way for consistency
373 }
374 elsif ( lc $search->{ 'key' } eq lc $self->key() ) {
375 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
376 # $match is always 1 at this point, left this way for consistency
377 }
378 else {
379 489 $match = 0;
380 }
381 }
382 else {
383 218 $match = 0;
384 }
385 }
386  
387 1273 ▶ if ( exists( $search->{ 'value' } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $search->{"value"}) 694 579 1273
388 694 ▶ $search->{ 'value' } = '' if ! defined $search->{ 'value' };
Branch: 1 branch
BranchTrueFalseTotal
unless defined $search->{"value"} 0 694 694
389 694 ▶ if ( $self->_HAS_VALUE() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_HAS_VALUE) { } 675 19 694
390 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
391 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
392 }
393 elsif ( lc $search->{ 'value' } eq lc $self->value() ) {
394 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
395 }
396 else {
397 518 $match = 0;
398 }
399 }
400 else {
401 19 $match = 0; # uncoverable statement
402 # There are no code paths with the current classes which end up here
403 }
404 }
405  
406 1273 ▶ if ( exists( $search->{ 'authserv_id' } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $search->{"authserv_id"}) 87 1186 1273
407 87 ▶ if ( $self->_HAS_VALUE() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_HAS_VALUE) { } 82 5 87
408 82 ▶ if ( lc ref $self eq 'mail::authenticationresults::header' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc ref $self eq 'mail::authenticationresults::header') { } 16 66 82
409 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
410 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
411 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
412 }
413 elsif ( lc $search->{ 'authserv_id' } eq lc $authserv_id ) {
414 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
415 }
416 else {
417 11 $match = 0;
418 }
419 }
420 else {
421 66 $match = 0;
422 }
423 }
424 else {
425 5 $match = 0; # uncoverable statement
426 # There are no code paths with the current classes which end up here
427 }
428 }
429  
430 1273 ▶ if ( exists( $search->{ 'isa' } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $search->{"isa"}) 447 826 1273
431 447 ▶ 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'})) { } 134 313 447
elsif (lc ref $self eq 'mail::authenticationresults::header' and lc $search->{'isa'} eq 'header') { } 5 308 313
432 134 ▶ $match = $match && 1;
Condition100%2/2
$match && 1
!ll
21113
MC/DC100%1/1
$match && 1
$match
Truth table100%2/2
A
A= $match
Aresult
00
11
433 }
434 ▶ 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
259495
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
435 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
436 }
437 else {
438 308 $match = 0;
439 }
440 }
441  
442 1273 ▶ if ( exists( $search->{ 'has' } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $search->{"has"}) 33 1240 1273
443 33 foreach my $query ( @{ $search->{ 'has' } } ) {
444 38 ▶ $match = 0 if ( scalar @{ $self->search( $query )->children() } == 0 );
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$self->search($query)->children;} == 0 23 15 38
445 }
446 }
447  
448 1273 ▶ if ( $match ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($match) 185 1088 1273
449 185 $group->add_child( $self );
450 }
451  
452 1273 ▶ if ( $self->_HAS_CHILDREN() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_HAS_CHILDREN) 1031 242 1273
453 1031 foreach my $child ( @{$self->children()} ) {
454 1120 my $childfound = $child->search( $search );
455 1120 ▶ if ( scalar @{ $childfound->children() } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$childfound->children;}) 214 906 1120
456 214 $group->add_child( $childfound );
457 }
458 }
459 }
460  
461 1273 return $group;
462 }
463  
464 30 1;
465  
466 __END__
« blib/lib/Mail/AuthenticationResults/Header.pm ↑ Summary lib/Mail/AuthenticationResults/Parser.pm »