Message/Head/FieldGroup.pm

filter: Statementstmt 67.0% 53 / 79 Branchbran 27.7% 5 / 18 Conditioncond 18.1% 2 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 66.6% 16 / 24 Podpod 94.7% 18 / 19 totaltotal 59.4% 94 / 158 CC 19 SCAR 25.4
CC
19
Cov
56%
details
56.0
print
12.0
init
7.4
CRAP 12.7
« Message/TransferEnc/Binary.pm ↑ Summary Message/Field/Date.pm »
1 # This code is part of Perl distribution Mail-Message version 4.05.
2 # The POD got stripped from this file by OODoc version 3.06.
3 # For contributors see file ChangeLog.
4  
5 # This software is copyright (c) 2001-2026 by Mark Overmeer.
6  
7 # This is free software; you can redistribute it and/or modify it under
8 # the same terms as the Perl 5 programming language system itself.
9 # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
10  
11  
12 package Mail::Message::Head::FieldGroup;{
13 5 our $VERSION = '4.05';
14 }
15  
16 5 ▶use parent 'Mail::Reporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 5 ▶use Log::Report 'mail-message', import => [ qw/trace/ ];
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 5 ▶use Scalar::Util qw/blessed/;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 #--------------------
26  
27 sub new(@)
28 78 ▶{ my $class = shift;
Subroutine new: called CC=2 SCAR=6.9
Pod documented
29  
30 78 my @fields;
31 78 ▶ push @fields, shift while blessed $_[0];
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($_[0]) and do { push @fields, shift() } 3 78 81
32  
33 78 $class->SUPER::new(@_, fields => \@fields);
34 }
35  
36 sub init($$)
37 78 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=7 SCAR=20.0
Pod undocumented
38 78 $self->SUPER::init($args);
39  
40 78 ▶ my $head = $self->{MMHF_head} = $args->{head} || Mail::Message::Head::Partial->new;
Condition66%2/3
$args->{'head'} || 'Mail::Message::Head::Partial'->new
l!l&&r!l&&!r
68100
MC/DC0%0/2
$args->{'head'} || 'Mail::Message::Head::Partial'->new
$args->{'head'} 'Mail::Message::Head::Partial'->new
Truth table66%2/3
A || B
A= $args->{'head'}B= 'Mail::Message::Head::Partial'->new
ABresult
1X1
011
000
41  
42 $self->add($_) # add specified object fields
43 78 for @{$args->{fields}};
44  
45 $self->add($_, delete $args->{$_}) # add key-value paired fields
46 78 for grep m/^[A-Z]/, keys %$args;
47  
48 78 ▶ $self->{MMHF_version} = $args->{version} if defined $args->{version};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"version"} 0 78 78
49 78 ▶ $self->{MMHF_software} = $args->{software} if defined $args->{software};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"software"} 0 78 78
50 78 ▶ $self->{MMHF_type} = $args->{type} if defined $args->{type};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"type"} 0 78 78
51 78 $self->{MMHF_fns} = [];
52 78 $self;
53 }
54  
55  
56 0 ▶sub implementedTypes() { $_[0]->notImplemented }
Subroutine implementedTypes: not called CC=1 SCAR=6.9
Pod documented
57  
58  
59 0 ▶sub from($) { $_[0]->notImplemented }
Subroutine from: not called CC=1 SCAR=6.9
Pod documented
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 386 ▶sub head() { $_[0]->{MMHF_head} }
Subroutine head: called CC=1 SCAR=0.0
Pod documented
72  
73  
74 sub attach($)
75 0 ▶{ my ($self, $head) = @_;
Subroutine attach: not called CC=2 SCAR=17.9
Pod documented
76 0 $head->add($_->clone) for $self->fields;
77 0 $self;
78 }
79  
80  
81 sub delete()
82 12 ▶{ my $self = shift;
Subroutine delete: called CC=2 SCAR=6.9
Pod documented
83 12 my $head = $self->head;
84 12 $head->removeField($_) for $self->fields;
85 12 $self;
86 }
87  
88  
89 sub add(@)
90 0 ▶{ my $self = shift;
Subroutine add: not called CC=2 SCAR=17.9
Pod documented
91 0 ▶ my $field = $self->head->add(@_) or return ();
Branch: 1 branch
BranchTrueFalseTotal
my $field = $self->head->add(@_) or return () 0 0 0
92 0 push @{$self->{MMHF_fns}}, $field->name;
93 0 $self;
94 }
95  
96  
97 sub fields()
98 75 ▶{ my $self = shift;
Subroutine fields: called CC=1 SCAR=0.0
Pod documented
99 75 my $head = $self->head;
100 75 map $head->get($_), $self->fieldNames;
101 }
102  
103  
104 75 ▶sub fieldNames() { @{ $_[0]->{MMHF_fns}} }
Subroutine fieldNames: called CC=1 SCAR=0.0
Pod documented
105  
106  
107 sub addFields(@)
108 53 ▶{ my $self = shift;
Subroutine addFields: called CC=1 SCAR=0.0
Pod documented
109 53 my $head = $self->head;
110  
111 53 push @{$self->{MMHF_fns}}, @_;
112 53 @_;
113 }
114  
115 #--------------------
116  
117 35 ▶sub version() { $_[0]->{MMHF_version} }
Subroutine version: called CC=1 SCAR=0.0
Pod documented
118  
119  
120 35 ▶sub software() { $_[0]->{MMHF_software} }
Subroutine software: called CC=1 SCAR=0.0
Pod documented
121  
122  
123 106 ▶sub type() { $_[0]->{MMHF_type} }
Subroutine type: called CC=1 SCAR=0.0
Pod documented
124  
125 #--------------------
126  
127 sub detected($$$)
128 51 ▶{ my $self = shift;
Subroutine detected: called CC=1 SCAR=0.0
Pod documented
129 51 @$self{ qw/MMHF_type MMHF_software MMHF_version/ } = @_;
130 }
131  
132  
133 0 ▶sub collectFields(;$) { $_[0]->notImplemented }
Subroutine collectFields: not called CC=1 SCAR=6.9
Pod documented
134  
135 #--------------------
136  
137 sub print(;$)
138 0 ▶{ my $self = shift;
Subroutine print: not called CC=3 SCAR=24.8
Pod documented
139 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
140 0 $_->print($out) for $self->fields;
141 }
142  
143  
144 sub details()
145 0 ▶{ my $self = shift;
Subroutine details: not called CC=7 SCAR=40.3
Pod documented
146 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
147  
148 0 my $software = $self->software;
149 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
150 0 my $version = $self->version;
151 0 ▶ my $release = defined $software
Branch: 3 branches
BranchTrueFalseTotal
defined $software ? : 0 0 0
defined $version ? : 0 0 0
defined $version ? : 0 0 0
152 ? (defined $version ? " ($software $version)" : " ($software)")
153 : (defined $version ? " ($version)" : '');
154  
155 0 my $fields = scalar $self->fields;
156 0 "$type $release, $fields fields";
157 }
158  
159 5 1;
« Message/TransferEnc/Binary.pm ↑ Summary Message/Field/Date.pm »