lib/Mail/AuthenticationResults/Header/Group.pm

filter: Statementstmt 100% 50 / 50 Branchbran 100% 26 / 26 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 100% 87 / 87 SCAR 28.3
CC
17
Cov
100%
_ALLOWED_CHILDREN
8.0
add_child
7.0
build_string
4.0
CRAP 17.0
« blib/lib/Mail/AuthenticationResults/Token/QuotedString.pm ↑ Summary lib/Mail/AuthenticationResults/Header/Comment.pm »
1 package Mail::AuthenticationResults::Header::Group;
2 # ABSTRACT: Class modelling Groups of Authentication Results Header parts
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{ refaddr };
Subroutine BEGIN: called CC=1 SCAR=0.0
9 29 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 29 ▶use base 'Mail::AuthenticationResults::Header::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 2269 ▶sub _HAS_CHILDREN{ return 1; }
Subroutine _HAS_CHILDREN: called CC=1 SCAR=0.0
15  
16 sub _ALLOWED_CHILDREN {
17 983 ▶ my ( $self, $child ) = @_;
Subroutine _ALLOWED_CHILDREN: called CC=8 SCAR=20.8
18 983 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header" 42 941 983
19 941 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header::AuthServID';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header::AuthServID" 4 937 941
20 937 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Comment';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header::Comment" 12 925 937
21 925 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Entry';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header::Entry" 516 409 925
22 409 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Group';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header::Group" 202 207 409
23 207 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header::SubEntry';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header::SubEntry" 202 5 207
24 5 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Version';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header::Version" 4 1 5
25 1 return 0;
26 }
27  
28 sub add_child {
29 593 ▶ my ( $self, $child ) = @_;
Subroutine add_child: called CC=7 SCAR=19.5
Pod documented
30 593 ▶ croak 'Cannot add child' if ! $self->_ALLOWED_CHILDREN( $child );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_ALLOWED_CHILDREN($child) 1 592 593
31 592 ▶ croak 'Cannot add a class as its own parent' if refaddr $self == refaddr $child;
Branch: 1 branch
BranchTrueFalseTotal
if builtin::refaddr($self) == builtin::refaddr($child) 1 591 592
32  
33 591 ▶ if ( ref $child eq 'Mail::AuthenticationResults::Header::Group' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $child eq 'Mail::AuthenticationResults::Header::Group') { } 201 390 591
34 201 foreach my $subchild ( @{ $child->children() } ) {
35 200 $self->add_child( $subchild );
36 }
37 ## ToDo what to return in this case?
38 }
39 else {
40 390 foreach my $current_child ( @{ $self->children() } ) {
41 282 ▶ if ( $current_child == $child ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($current_child == $child) 6 276 282
42 6 return $child;
43 }
44 }
45 384 $self->SUPER::add_child( $child );
46 }
47  
48 585 return $child;
49 }
50  
51 sub build_string {
52 18 ▶ my ( $self, $header ) = @_;
Subroutine build_string: called CC=4 SCAR=13.9
Pod documented
53  
54 18 my $sep = 0;
55 18 foreach my $child ( @{ $self->children() } ) {
56 20 ▶ $header->separator( ';' ) if $sep;
Branch: 1 branch
BranchTrueFalseTotal
if $sep 5 15 20
57 20 ▶ $header->space( "\n" ) if $sep;
Branch: 1 branch
BranchTrueFalseTotal
if $sep 5 15 20
58 20 $sep = 1;
59 20 $child->build_string( $header );
60 }
61  
62 18 return;
63 }
64  
65 29 1;
66  
67 __END__
« blib/lib/Mail/AuthenticationResults/Token/QuotedString.pm ↑ Summary lib/Mail/AuthenticationResults/Header/Comment.pm »