« 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
| |||||||||||
| 19 | 1016 | ▶ | return 1 if ref $child eq 'Mail::AuthenticationResults::Header::AuthServID'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 1012 | ▶ | return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Comment'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 1000 | ▶ | return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Entry'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 424 | ▶ | return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Group'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 207 | ▶ | 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 | 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
| |||||||||||
| 31 | 637 | ▶ | croak 'Cannot add a class as its own parent' if refaddr $self == refaddr $child; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | |||||||||||
| 33 | 636 | ▶ | if ( ref $child eq 'Mail::AuthenticationResults::Header::Group' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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 | 30 | 1; | |||||||||
| 66 | |||||||||||
| 67 | __END__ | ||||||||||