Message/Head/FieldGroup.pm

filter: Statementstmt 39.4% 30 / 76 Branchbran 27.7% 5 / 18 Conditioncond 9.0% 1 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 30.4% 7 / 23 Podpod 94.7% 18 / 19 totaltotal 39.6% 61 / 154 SCAR 48.0
CC
19
Cov
34%
details
56.0
print
12.0
init
7.8
CRAP 121.4
« Message/Head/Partial.pm ↑ Summary Message/Construct/Forward.pm »
1 # Copyrights 2001-2023 by [Mark Overmeer <markov@cpan.org>].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.03.
5 # This code is part of distribution Mail-Message. Meta-POD processed with
6 # OODoc into POD and HTML manual-pages. See README.md
7 # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8  
9 package Mail::Message::Head::FieldGroup;
10 5 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 $VERSION = '3.013';
12  
13 5 ▶use base 'Mail::Reporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 sub new(@)
20 6 ▶{ my $class = shift;
Subroutine new: called CC=2 SCAR=6.9
Pod documented
21  
22 6 my @fields;
23 6 ▶ push @fields, shift while ref $_[0];
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] and do { push @fields, shift() } 3 6 9
24  
25 6 $class->SUPER::new(@_, fields => \@fields);
26 }
27  
28 sub init($$)
29 6 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=7 SCAR=20.5
Pod undocumented
30 6 $self->SUPER::init($args);
31  
32 my $head = $self->{MMHF_head}
33 6 ▶ = $args->{head} || Mail::Message::Head::Partial->new;
Condition33%1/3
$args->{'head'} || 'Mail::Message::Head::Partial'->new
l!l&&r!l&&!r
006
MC/DC0%0/2
$args->{'head'} || 'Mail::Message::Head::Partial'->new
$args->{'head'} 'Mail::Message::Head::Partial'->new
Truth table33%1/3
A || B
A= $args->{'head'}B= 'Mail::Message::Head::Partial'->new
ABresult
1X1
011
000
34  
35 $self->add($_) # add specified object fields
36 6 foreach @{$args->{fields}};
37  
38 $self->add($_, delete $args->{$_}) # add key-value paired fields
39 6 foreach grep m/^[A-Z]/, keys %$args;
40  
41 6 ▶ $self->{MMHF_version} = $args->{version} if defined $args->{version};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"version"} 0 6 6
42 6 ▶ $self->{MMHF_software} = $args->{software} if defined $args->{software};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"software"} 0 6 6
43 6 ▶ $self->{MMHF_type} = $args->{type} if defined $args->{type};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"type"} 0 6 6
44  
45 6 $self->{MMHF_fns} = [];
46 6 $self;
47 }
48  
49 #------------------------------------------
50  
51  
52 0 ▶sub implementedTypes() { shift->notImplemented }
Subroutine implementedTypes: not called CC=1 SCAR=6.9
Pod documented
53  
54 #------------------------------------------
55  
56  
57 0 ▶sub from($) { shift->notImplemented }
Subroutine from: not called CC=1 SCAR=6.9
Pod documented
58  
59 #------------------------------------------
60  
61  
62 sub clone()
63 0 ▶{ my $self = shift;
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
64 0 my $clone = bless %$self, ref $self;
65 0 $clone->{MMHF_fns} = [ $self->fieldNames ];
66 0 $clone;
67 }
68  
69 #------------------------------------------
70  
71  
72 51 ▶sub head() { shift->{MMHF_head} }
Subroutine head: called CC=1 SCAR=0.0
Pod documented
73  
74 #------------------------------------------
75  
76  
77 sub attach($)
78 0 ▶{ my ($self, $head) = @_;
Subroutine attach: not called CC=2 SCAR=17.9
Pod documented
79 0 $head->add($_->clone) for $self->fields;
80 0 $self;
81 }
82  
83 #------------------------------------------
84  
85  
86 sub delete()
87 0 ▶{ my $self = shift;
Subroutine delete: not called CC=2 SCAR=17.9
Pod documented
88 0 my $head = $self->head;
89 0 $head->removeField($_) foreach $self->fields;
90 0 $self;
91 }
92  
93 #------------------------------------------
94  
95  
96 sub add(@)
97 0 ▶{ my $self = shift;
Subroutine add: not called CC=2 SCAR=17.9
Pod documented
98 0 ▶ my $field = $self->head->add(@_) or return ();
Branch: 1 branch
BranchTrueFalseTotal
my $field = $self->head->add(@_) or return () 0 0 0
99 0 push @{$self->{MMHF_fns}}, $field->name;
100 0 $self;
101 }
102  
103 #------------------------------------------
104  
105  
106 sub fields()
107 0 ▶{ my $self = shift;
Subroutine fields: not called CC=1 SCAR=6.9
Pod documented
108 0 my $head = $self->head;
109 0 map { $head->get($_) } $self->fieldNames;
110 }
111  
112 #------------------------------------------
113  
114  
115 0 ▶sub fieldNames() { @{shift->{MMHF_fns}} }
Subroutine fieldNames: not called CC=1 SCAR=6.9
Pod documented
116  
117 #------------------------------------------
118  
119  
120 sub addFields(@)
121 0 ▶{ my $self = shift;
Subroutine addFields: not called CC=1 SCAR=6.9
Pod documented
122 0 my $head = $self->head;
123  
124 0 push @{$self->{MMHF_fns}}, @_;
125 0 @_;
126 }
127  
128 #------------------------------------------
129  
130  
131 0 ▶sub version() { shift->{MMHF_version} }
Subroutine version: not called CC=1 SCAR=6.9
Pod documented
132  
133 #------------------------------------------
134  
135  
136 0 ▶sub software() { shift->{MMHF_software} }
Subroutine software: not called CC=1 SCAR=6.9
Pod documented
137  
138 #------------------------------------------
139  
140  
141 0 ▶sub type() { shift->{MMHF_type} }
Subroutine type: not called CC=1 SCAR=6.9
Pod documented
142  
143 #------------------------------------------
144  
145  
146 sub detected($$$)
147 0 ▶{ my $self = shift;
Subroutine detected: not called CC=1 SCAR=6.9
Pod documented
148 0 @$self{ qw/MMHF_type MMHF_software MMHF_version/ } = @_;
149 }
150  
151 #------------------------------------------
152  
153  
154 0 ▶sub collectFields(;$) { shift->notImplemented }
Subroutine collectFields: not called CC=1 SCAR=6.9
Pod documented
155  
156 #------------------------------------------
157  
158  
159 sub print(;$)
160 0 ▶{ my $self = shift;
Subroutine print: not called CC=3 SCAR=24.8
Pod documented
161 0 ▶ my $out = shift || select;
Condition0%0/3
shift() || select()
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || select()
shift() select()
Truth table0%0/3
A || B
A= shift()B= select()
ABresult
1X1
011
000
162 0 $_->print($out) foreach $self->fields;
163 }
164  
165 #------------------------------------------
166  
167  
168 sub details()
169 0 ▶{ my $self = shift;
Subroutine details: not called CC=7 SCAR=40.3
Pod documented
170 0 ▶ my $type = $self->type || 'Unknown';
Condition0%0/2
$self->type || 'Unknown'
l!l
00
MC/DC0%0/1
$self->type || 'Unknown'
$self->type
Truth table0%0/2
A
A= $self->type
Aresult
11
00
171  
172 0 my $software = $self->software;
173 0 ▶ undef $software if defined($software) && $type eq $software;
Branch: 1 branch
BranchTrueFalseTotal
if defined $software and $type eq $software 0 0 0
Condition0%0/3
defined $software and $type eq $software
!ll&&!rl&&r
000
MC/DC0%0/2
defined $software and $type eq $software
defined $software $type eq $software
Truth table0%0/3
A and B
A= defined $softwareB= $type eq $software
ABresult
0X0
100
111
174 0 my $version = $self->version;
175 0 ▶ my $release
Branch: 3 branches
BranchTrueFalseTotal
defined $software ? : 0 0 0
defined $version ? : 0 0 0
defined $version ? : 0 0 0
176 = defined $software
177 ? (defined $version ? " ($software $version)" : " ($software)")
178 : (defined $version ? " ($version)" : '');
179  
180 0 my $fields = scalar $self->fields;
181 0 "$type $release, $fields fields";
182 }
183  
184 #------------------------------------------
185  
186 5 1;
« Message/Head/Partial.pm ↑ Summary Message/Construct/Forward.pm »