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 blib/lib/Mail/AuthenticationResults/Header/SubEntry.pm »
1 package Mail::AuthenticationResults::Header::Group;
2 # ABSTRACT: Class modelling Groups of Authentication Results Header parts
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{ refaddr };
Subroutine BEGIN: called CC=1 SCAR=0.0
9 30 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 30 ▶use base 'Mail::AuthenticationResults::Header::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 2379 ▶sub _HAS_CHILDREN{ return 1; }
Subroutine _HAS_CHILDREN: called CC=1 SCAR=0.0
15  
16 1058 ▶sub _ALLOWED_CHILDREN {
Subroutine _ALLOWED_CHILDREN: called CC=8 SCAR=20.8
17 1058 my ( $self, $child ) = @_;
18 1058 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header" 42 1016 1058
19 1016 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header::AuthServID';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header::AuthServID" 4 1012 1016
20 1012 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Comment';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header::Comment" 12 1000 1012
21 1000 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Entry';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header::Entry" 576 424 1000
22 424 ▶ return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Group';
Branch: 1 branch
BranchTrueFalseTotal
if ref $child eq "Mail::AuthenticationResults::Header::Group" 217 207 424
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 638 ▶sub add_child {
Subroutine add_child: called CC=7 SCAR=19.5
Pod documented
29 638 my ( $self, $child ) = @_;
30 638 ▶ croak 'Cannot add child' if ! $self->_ALLOWED_CHILDREN( $child );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_ALLOWED_CHILDREN($child) 1 637 638
31 637 ▶ 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 636 637
32  
33 636 ▶ if ( ref $child eq 'Mail::AuthenticationResults::Header::Group' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $child eq 'Mail::AuthenticationResults::Header::Group') { } 216 420 636
34 216 foreach my $subchild ( @{ $child->children() } ) {
35 215 $self->add_child( $subchild );
36 }
37 ## ToDo what to return in this case?
38 }
39 else {
40 420 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 414 $self->SUPER::add_child( $child );
46 }
47  
48 630 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 30 1;
66  
67 __END__
« lib/Mail/AuthenticationResults/Header/Comment.pm ↑ Summary blib/lib/Mail/AuthenticationResults/Header/SubEntry.pm »