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 CC 17 SCAR 16.9
CC
17
Cov
100%
_ALLOWED_CHILDREN
8.0
add_child
7.0
build_string
4.0
CRAP 5.4
« lib/Mail/AuthenticationResults/Header/Comment.pm ↑ Summary lib/Mail/AuthenticationResults/Token/Comment.pm »
1 package Mail::AuthenticationResults::Header::Group;
2 # ABSTRACT: Class modelling Groups of Authentication Results Header parts
3  
4 31 require 5.008;
5 31 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 31 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 31 our $VERSION = '2.20261029'; # VERSION
8 31 ▶use Scalar::Util qw{ refaddr };
Subroutine BEGIN: called CC=1 SCAR=0.0
9 31 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 31 ▶use base 'Mail::AuthenticationResults::Header::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 2388 ▶sub _HAS_CHILDREN{ return 1; }
Subroutine _HAS_CHILDREN: called CC=1 SCAR=0.0
15  
16 1063 ▶sub _ALLOWED_CHILDREN {
Subroutine _ALLOWED_CHILDREN: called CC=8 SCAR=20.8
17 1063 my ( $self, $child ) = @_;
18 1063 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header" 42 1021 1063
19 1021 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header::AuthServID';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header::AuthServID" 4 1017 1021
20 1017 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Comment';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header::Comment" 12 1005 1017
21 1005 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Entry';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header::Entry" 576 429 1005
22 429 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Group';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header::Group" 218 211 429
23 211 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header::SubEntry';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header::SubEntry" 206 5 211
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 641 ▶sub add_child {
Subroutine add_child: called CC=7 SCAR=19.5
Pod documented
29 641 my ( $self, $child ) = @_;
30 641 ▶ croak 'Cannot add child' if ! $self->_ALLOWED_CHILDREN( $child );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_ALLOWED_CHILDREN($child) 1 640 641
31 640 ▶ 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 639 640
32  
33 639 ▶ if ( ref $child eq 'Mail::AuthenticationResults::Header::Group' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $child eq 'Mail::AuthenticationResults::Header::Group') { } 217 422 639
34 217 foreach my $subchild ( @{ $child->children() } ) {
35 216 $self->add_child( $subchild );
36 }
37 ## ToDo what to return in this case?
38 }
39 else {
40 422 foreach my $current_child ( @{ $self->children() } ) {
41 350 ▶ if ( $current_child == $child ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($current_child == $child) 6 344 350
42 6 return $child;
43 }
44 }
45 416 $self->SUPER::add_child( $child );
46 }
47  
48 633 return $child;
49 }
50  
51 18 ▶sub build_string {
Subroutine build_string: called CC=4 SCAR=13.9
Pod documented
52 18 my ( $self, $header ) = @_;
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 31 1;
66  
67 __END__
« lib/Mail/AuthenticationResults/Header/Comment.pm ↑ Summary lib/Mail/AuthenticationResults/Token/Comment.pm »