← Index
NYTProf Performance Profile   « line view »
For /usr/local/libexec/sympa/task_manager-debug.pl
  Run on Tue Jun 1 22:32:51 2021
Reported on Tue Jun 1 22:35:14 2021

Filename/usr/local/lib/perl5/site_perl/Mail/AuthenticationResults/Header.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sMail::AuthenticationResults::Header::::BEGIN@10Mail::AuthenticationResults::Header::BEGIN@10
0000s0sMail::AuthenticationResults::Header::::BEGIN@12Mail::AuthenticationResults::Header::BEGIN@12
0000s0sMail::AuthenticationResults::Header::::BEGIN@5Mail::AuthenticationResults::Header::BEGIN@5
0000s0sMail::AuthenticationResults::Header::::BEGIN@6Mail::AuthenticationResults::Header::BEGIN@6
0000s0sMail::AuthenticationResults::Header::::BEGIN@8Mail::AuthenticationResults::Header::BEGIN@8
0000s0sMail::AuthenticationResults::Header::::_ALLOWED_CHILDRENMail::AuthenticationResults::Header::_ALLOWED_CHILDREN
0000s0sMail::AuthenticationResults::Header::::_HAS_CHILDRENMail::AuthenticationResults::Header::_HAS_CHILDREN
0000s0sMail::AuthenticationResults::Header::::_HAS_VALUEMail::AuthenticationResults::Header::_HAS_VALUE
0000s0sMail::AuthenticationResults::Header::::__ANON__Mail::AuthenticationResults::Header::__ANON__ (xsub)
0000s0sMail::AuthenticationResults::Header::::_as_hashrefMail::AuthenticationResults::Header::_as_hashref
0000s0sMail::AuthenticationResults::Header::::add_childMail::AuthenticationResults::Header::add_child
0000s0sMail::AuthenticationResults::Header::::add_parentMail::AuthenticationResults::Header::add_parent
0000s0sMail::AuthenticationResults::Header::::as_stringMail::AuthenticationResults::Header::as_string
0000s0sMail::AuthenticationResults::Header::::build_stringMail::AuthenticationResults::Header::build_string
0000s0sMail::AuthenticationResults::Header::::clear_indent_onMail::AuthenticationResults::Header::clear_indent_on
0000s0sMail::AuthenticationResults::Header::::eolMail::AuthenticationResults::Header::eol
0000s0sMail::AuthenticationResults::Header::::fold_atMail::AuthenticationResults::Header::fold_at
0000s0sMail::AuthenticationResults::Header::::force_fold_atMail::AuthenticationResults::Header::force_fold_at
0000s0sMail::AuthenticationResults::Header::::indent_byMail::AuthenticationResults::Header::indent_by
0000s0sMail::AuthenticationResults::Header::::indent_onMail::AuthenticationResults::Header::indent_on
0000s0sMail::AuthenticationResults::Header::::safe_set_valueMail::AuthenticationResults::Header::safe_set_value
0000s0sMail::AuthenticationResults::Header::::set_eolMail::AuthenticationResults::Header::set_eol
0000s0sMail::AuthenticationResults::Header::::set_fold_atMail::AuthenticationResults::Header::set_fold_at
0000s0sMail::AuthenticationResults::Header::::set_force_fold_atMail::AuthenticationResults::Header::set_force_fold_at
0000s0sMail::AuthenticationResults::Header::::set_indent_byMail::AuthenticationResults::Header::set_indent_by
0000s0sMail::AuthenticationResults::Header::::set_indent_onMail::AuthenticationResults::Header::set_indent_on
0000s0sMail::AuthenticationResults::Header::::set_indent_styleMail::AuthenticationResults::Header::set_indent_style
0000s0sMail::AuthenticationResults::Header::::set_valueMail::AuthenticationResults::Header::set_value
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Mail::AuthenticationResults::Header;
2# ABSTRACT: Class modelling the Entire Authentication Results Header set
3
4require 5.008;
5use strict;
6use warnings;
7our $VERSION = '2.20210112'; # VERSION
8use Carp;
9
10use Mail::AuthenticationResults::Header::AuthServID;
11
12use base 'Mail::AuthenticationResults::Header::Base';
13
14
15sub _HAS_VALUE{ return 1; }
16sub _HAS_CHILDREN{ return 1; }
17
18sub _ALLOWED_CHILDREN {
19 my ( $self, $child ) = @_;
20 return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Comment';
21 return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Entry';
22 return 0;
23}
24
25
26sub set_indent_by {
27 my ( $self, $value ) = @_;
28 $self->{ 'indent_by' } = $value;
29 return $self;
30}
31
32
33sub indent_by {
34 my ( $self ) = @_;
35 return 4 if ! defined $self->{ 'indent_by' }; #5.8
36 return $self->{ 'indent_by'};
37}
38
39
40sub set_indent_on {
41 my ( $self, $type ) = @_;
42 $self->{ 'indent_type_' . $type } = 1;
43 return $self;
44}
45
46
47sub clear_indent_on {
48 my ( $self, $type ) = @_;
49 $self->{ 'indent_type_' . $type } = 0;
50 return $self;
51}
52
53
54sub indent_on {
55 my ( $self, $type ) = @_;
56 if ( $type eq 'Mail::AuthenticationResults::Header::Entry' ) {
57 return 1 if ! defined $self->{ 'indent_type_' . $type }; #5.8
58 return $self->{ 'indent_type_' . $type };
59 }
60 if ( $type eq 'Mail::AuthenticationResults::Header::SubEntry' ) {
61 return 0 if ! defined $self->{ 'indent_type_' . $type }; #5.8
62 return $self->{ 'indent_type_' . $type };
63 }
64 elsif ( $type eq 'Mail::AuthenticationResults::Header::Comment' ) {
65 return 0 if ! defined $self->{ 'indent_type_' . $type }; #5.8
66 return $self->{ 'indent_type_' . $type };
67 }
68 return 0;
69}
70
71
72sub set_eol {
73 my ( $self, $eol ) = @_;
74 if ( $eol =~ /^\r?\n$/ ) {
75 $self->{ 'eol' } = $eol;
76 }
77 else {
78 croak 'Invalid eol string';
79 }
80 return $self;
81}
82
83
84sub eol {
85 my ( $self ) = @_;
86 return "\n" if ! defined $self->{ 'eol' }; #5.8
87 return $self->{ 'eol' };
88}
89
90
91sub fold_at {
92 my ( $self ) = @_;
93 return $self->{ 'fold_at' };
94}
95
96
97sub set_fold_at {
98 my ( $self, $fold_at ) = @_;
99 $self->{ 'fold_at' } = $fold_at;
100 return $self;
101}
102
103
104sub force_fold_at {
105 my ( $self ) = @_;
106 return $self->{ 'force_fold_at' };
107}
108
109
110sub set_force_fold_at {
111 my ( $self, $fold_at ) = @_;
112 $self->{ 'force_fold_at' } = $fold_at;
113 return $self;
114}
115
116
117sub set_indent_style {
118 my ( $self, $style ) = @_;
119
120 if ( $style eq 'none' ) {
121 $self->clear_indent_on( 'Mail::AuthenticationResults::Header::Entry' );
122 $self->clear_indent_on( 'Mail::AuthenticationResults::Header::SubEntry' );
123 $self->clear_indent_on( 'Mail::AuthenticationResults::Header::Comment' );
124 }
125 elsif ( $style eq 'entry' ) {
126 $self->set_indent_by( 4 );
127 $self->set_indent_on( 'Mail::AuthenticationResults::Header::Entry' );
128 $self->clear_indent_on( 'Mail::AuthenticationResults::Header::SubEntry' );
129 $self->clear_indent_on( 'Mail::AuthenticationResults::Header::Comment' );
130 }
131 elsif ( $style eq 'subentry' ) {
132 $self->set_indent_by( 4 );
133 $self->set_indent_on( 'Mail::AuthenticationResults::Header::Entry' );
134 $self->set_indent_on( 'Mail::AuthenticationResults::Header::SubEntry' );
135 $self->clear_indent_on( 'Mail::AuthenticationResults::Header::Comment' );
136 }
137 elsif ( $style eq 'full' ) {
138 $self->set_indent_by( 4 );
139 $self->set_indent_on( 'Mail::AuthenticationResults::Header::Entry' );
140 $self->set_indent_on( 'Mail::AuthenticationResults::Header::SubEntry' );
141 $self->set_indent_on( 'Mail::AuthenticationResults::Header::Comment' );
142 }
143 else {
144 croak "Unknown indent style $style";
145 }
146
147 return $self;
148}
149
150sub safe_set_value {
151 my ( $self, $value ) = @_;
152 $self->set_value( $value );
153 return $self;
154}
155
156sub set_value {
157 my ( $self, $value ) = @_;
158 croak 'Does not have value' if ! $self->_HAS_VALUE(); # uncoverable branch true
159 # HAS_VALUE is 1 for this class
160 croak 'Value cannot be undefined' if ! defined $value;
161 croak 'value should be an AuthServID type' if ref $value ne 'Mail::AuthenticationResults::Header::AuthServID';
162 $self->{ 'value' } = $value;
163 return $self;
164}
165
166sub add_parent {
167 my ( $self, $parent ) = @_;
168 return;
169}
170
171sub add_child {
172 my ( $self, $child ) = @_;
173 croak 'Cannot add a SubEntry as a child of a Header' if ref $child eq 'Mail::AuthenticationResults::Header::SubEntry';
174 return $self->SUPER::add_child( $child );
175}
176
177sub _as_hashref {
178 my ( $self ) = @_;
179
180 my $type = lc ref $self;
181 $type =~ s/^(.*::)//;
182 my $hashref = { 'type' => $type };
183
184 $hashref->{'key'} = $self->key() if $self->_HAS_KEY();
185 $hashref->{'authserv_id'} = $self->value()->_as_hashref() if $self->value();
186 if ( $self->_HAS_CHILDREN() ) {
187 my @children = map { $_->_as_hashref() } @{ $self->children() };
188 $hashref->{'children'} = \@children;
189 }
190 return $hashref;
191}
192
193sub as_string {
194 my ( $self ) = @_;
195 my $header = Mail::AuthenticationResults::FoldableHeader->new();
196 $header->set_try_fold_at( $self->fold_at() ) if defined $self->fold_at();
197 $header->set_force_fold_at( $self->force_fold_at() ) if defined $self->force_fold_at();
198 $header->set_eol( $self->eol() );
199 $header->set_indent( ' ' x $self->indent_by() );
200 $header->set_sub_indent( ' ' );
201 $self->build_string( $header );
202 return $header->as_string();
203}
204
205sub build_string {
206 my ( $self, $header ) = @_;
207 my $value = q{};
208 if ( $self->value() ) {
209 $self->value()->build_string( $header );
210 }
211 else {
212 $header->string( 'unknown' );
213 }
214 $header->separator( ';' );
215
216 my $sep = 0;
217 foreach my $child ( @{ $self->children() } ) {
218 $header->separator( ';' ) if $sep;
219 $sep = 1;
220 $child->as_string_prefix( $header );
221 $child->build_string( $header );
222 }
223
224 if ( scalar @{ $self->search({ 'isa' => 'entry' } )->children() } == 0 ) {
225 #if ( scalar @{ $self->children() } > 0 ) {
226 # $value .= ' ';
227 #}
228 $header->space( ' ' );
229 $header->string ( 'none' );
230 }
231
232 return;
233}
234
2351;
236
237__END__