« 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
| |||||||||||
| 19 | 1021 | ▶ | return 1 if ref $child eq 'Mail::AuthenticationResults::Header::AuthServID'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 1017 | ▶ | return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Comment'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 1005 | ▶ | return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Entry'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 429 | ▶ | return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Group'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 211 | ▶ | return 1 if ref $child eq 'Mail::AuthenticationResults::Header::SubEntry'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 5 | ▶ | return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Version'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 31 | 640 | ▶ | croak 'Cannot add a class as its own parent' if refaddr $self == refaddr $child; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | |||||||||||
| 33 | 639 | ▶ | if ( ref $child eq 'Mail::AuthenticationResults::Header::Group' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 57 | 20 | ▶ | $header->space( "\n" ) if $sep; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | 20 | $sep = 1; | |||||||||
| 59 | 20 | $child->build_string( $header ); | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 18 | return; | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 31 | 1; | |||||||||
| 66 | |||||||||||
| 67 | __END__ | ||||||||||