Message/Body/Multipart.pm

filter: Statementstmt 85.4% 200 / 234 Branchbran 73.0% 95 / 130 Conditioncond 59.3% 19 / 32 MC/DCmcdc 23.8% 5 / 21 Subroutinesub 79.4% 27 / 34 Podpod 91.3% 21 / 23 totaltotal 77.4% 367 / 474 SCAR 50.4
CC
87
Cov
79%
init
20.7
read
17.6
print
14.9
CRAP 154.2
« Box/FastScalar.pm ↑ Summary Message/Head/Partial.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::Body::Multipart;
10 34 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 34 $VERSION = '3.013';
12  
13 34 ▶use base 'Mail::Message::Body';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 34 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 34 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 34 ▶use Mail::Message::Body::Lines;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 34 ▶use Mail::Message::Part;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 34 ▶use Mail::Box::FastScalar;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 34 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24  
25 sub init($)
26 41 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=19 SCAR=30.3
Pod undocumented
27 41 my $based = $args->{based_on};
28 41 ▶ $args->{mime_type} ||= defined $based ? $based->type : 'multipart/mixed';
Branch: 1 branch
BranchTrueFalseTotal
defined $based ? : 24 15 39
Condition66%2/3
$args->{"mime_type"} ||= defined $based ? $based->type : "multipart/mixed"
l!l&&r!l&&!r
2390
MC/DC0%0/2
$args->{"mime_type"} ||= defined $based ? $based->type : "multipart/mixed"
$args->{"mime_type"} defined $based ? $based->type : "multipart/mixed"
Truth table66%2/3
A ||= B
A= $args->{"mime_type"}B= defined $based ? $based->type : "multipart/mixed"
ABresult
1X1
011
000
29  
30 41 $self->SUPER::init($args);
31  
32 41 my @parts;
33 41 ▶ if($args->{parts})
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"parts"}) 32 9 41
34 32 { foreach my $raw (@{$args->{parts}})
35 56 ▶ { next unless defined $raw;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $raw 0 56 56
36 56 my $cooked = Mail::Message::Part->coerce($raw, $self);
37  
38 56 ▶ $self->log(ERROR => 'Data not convertible to a message (type is '
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cooked 0 56 56
39 , ref $raw,")\n"), next unless defined $cooked;
40  
41 56 push @parts, $cooked;
42 }
43 }
44  
45 41 my $preamble = $args->{preamble};
46 41 ▶ $preamble = Mail::Message::Body->new(data => $preamble)
Branch: 1 branch
BranchTrueFalseTotal
if defined $preamble and not ref $preamble 0 41 41
Condition66%2/3
defined $preamble and not ref $preamble
!ll&&!rl&&r
3650
MC/DC0%0/2
defined $preamble and not ref $preamble
defined $preamble not ref $preamble
Truth table66%2/3
A and not(B)
A= defined $preambleB= not ref $preamble
ABresult
0X0
100
111
47 if defined $preamble && ! ref $preamble;
48
49 41 my $epilogue = $args->{epilogue};
50 41 ▶ $epilogue = Mail::Message::Body->new(data => $epilogue)
Branch: 1 branch
BranchTrueFalseTotal
if defined $epilogue and not ref $epilogue 0 41 41
Condition66%2/3
defined $epilogue and not ref $epilogue
!ll&&!rl&&r
3650
MC/DC0%0/2
defined $epilogue and not ref $epilogue
defined $epilogue not ref $epilogue
Truth table66%2/3
A and not(B)
A= defined $epilogueB= not ref $epilogue
ABresult
0X0
100
111
51 if defined $epilogue && ! ref $epilogue;
52
53 41 ▶ if($based)
Branch: 1 branch
BranchTrueFalseTotal
if ($based) { } 24 17 41
54 24 ▶ { $self->boundary($args->{boundary} || $based->boundary);
Condition33%1/3
$args->{'boundary'} || $based->boundary
l!l&&r!l&&!r
0240
MC/DC0%0/2
$args->{'boundary'} || $based->boundary
$args->{'boundary'} $based->boundary
Truth table33%1/3
A || B
A= $args->{'boundary'}B= $based->boundary
ABresult
1X1
011
000
55 $self->{MMBM_preamble}
56 24 ▶ = defined $preamble ? $preamble : $based->preamble;
Branch: 1 branch
BranchTrueFalseTotal
defined $preamble ? : 5 19 24
57  
58 $self->{MMBM_parts}
59 = @parts ? \@parts
60 24 ▶ : !$args->{parts} && $based->isMultipart
Branch: 2 branches
BranchTrueFalseTotal
@parts ? : 21 3 24
!$args->{'parts'} && $based->isMultipart ? : 1 2 3
Condition66%2/3
not $args->{"parts"} and $based->isMultipart
!ll&&!rl&&r
201
MC/DC50%1/2
not $args->{"parts"} and $based->isMultipart
not $args->{"parts"} $based->isMultipart
Truth table66%2/3
not(A) and B
A= not $args->{"parts"}B= $based->isMultipart
ABresult
0X0
100
111
61 ? [ $based->parts('ACTIVE') ]
62 : [];
63  
64 $self->{MMBM_epilogue}
65 24 ▶ = defined $epilogue ? $epilogue : $based->epilogue;
Branch: 1 branch
BranchTrueFalseTotal
defined $epilogue ? : 5 19 24
66 }
67 else
68 17 ▶ { $self->boundary($args->{boundary} ||$self->type->attribute('boundary'));
Condition66%2/3
$args->{'boundary'} || $self->type->attribute('boundary')
l!l&&r!l&&!r
1016
MC/DC50%1/2
$args->{'boundary'} || $self->type->attribute('boundary')
$args->{'boundary'} $self->type->attribute('boundary')
Truth table66%2/3
A || B
A= $args->{'boundary'}B= $self->type->attribute('boundary')
ABresult
1X1
011
000
69 17 $self->{MMBM_preamble} = $preamble;
70 17 $self->{MMBM_parts} = \@parts;
71 17 $self->{MMBM_epilogue} = $epilogue;
72 }
73  
74 41 $self;
75 }
76  
77 sub isMultipart() {1}
78  
79 # A multipart body is never binary itself. The parts may be.
80 sub isBinary() {0}
81  
82 sub clone()
83 3 ▶{ my $self = shift;
Subroutine clone: called CC=3 SCAR=11.0
Pod documented
84 3 my $preamble = $self->preamble;
85 3 my $epilogue = $self->epilogue;
86  
87 my $body = ref($self)->new
88 ( $self->logSettings
89 , based_on => $self
90 , preamble => ($preamble ? $preamble->clone : undef)
91 , epilogue => ($epilogue ? $epilogue->clone : undef)
92 3 ▶ , parts => [ map {$_->clone} $self->parts('ACTIVE') ]
Branch: 2 branches
BranchTrueFalseTotal
$preamble ? : 2 1 3
$epilogue ? : 2 1 3
93 );
94  
95 }
96  
97 sub nrLines()
98 23 ▶{ my $self = shift;
Subroutine nrLines: called CC=6 SCAR=17.9
Pod documented
99 23 my $nr = 1; # trailing part-sep
100  
101 23 ▶ if(my $preamble = $self->preamble)
Branch: 1 branch
BranchTrueFalseTotal
if (my $preamble = $self->preamble) 3 20 23
102 3 { $nr += $preamble->nrLines;
103 3 ▶ $nr++ if $preamble->endsOnNewline;
Branch: 1 branch
BranchTrueFalseTotal
if $preamble->endsOnNewline 3 0 3
104 }
105  
106 23 foreach my $part ($self->parts('ACTIVE'))
107 35 { $nr += 1 + $part->nrLines;
108 35 ▶ $nr++ if $part->body->endsOnNewline;
Branch: 1 branch
BranchTrueFalseTotal
if $part->body->endsOnNewline 33 2 35
109 }
110  
111 23 ▶ if(my $epilogue = $self->epilogue)
Branch: 1 branch
BranchTrueFalseTotal
if (my $epilogue = $self->epilogue) 3 20 23
112 3 { $nr += $epilogue->nrLines;
113 }
114  
115 23 $nr;
116 }
117  
118 sub size()
119 27 ▶{ my $self = shift;
Subroutine size: called CC=4 SCAR=13.9
Pod documented
120 27 my $bbytes = length($self->boundary) +4; # \n--$b\n
121  
122 27 my $bytes = $bbytes +2; # last boundary, \n--$b--\n
123 27 ▶ if(my $preamble = $self->preamble)
Branch: 1 branch
BranchTrueFalseTotal
if (my $preamble = $self->preamble) { } 6 21 27
124 6 { $bytes += $preamble->size }
125 21 else { $bytes -= 1 } # no leading \n
126  
127 27 $bytes += $bbytes + $_->size foreach $self->parts('ACTIVE');
128 27 ▶ if(my $epilogue = $self->epilogue)
Branch: 1 branch
BranchTrueFalseTotal
if (my $epilogue = $self->epilogue) 7 20 27
129 7 { $bytes += $epilogue->size;
130 }
131 27 $bytes;
132 }
133  
134 4 ▶sub string() { join '', shift->lines }
Subroutine string: called CC=1 SCAR=0.0
Pod documented
135  
136 sub lines()
137 4 ▶{ my $self = shift;
Subroutine lines: called CC=9 SCAR=24.4
Pod documented
138  
139 4 my $boundary = $self->boundary;
140 4 my @lines;
141  
142 4 my $preamble = $self->preamble;
143 4 ▶ push @lines, $preamble->lines if $preamble;
Branch: 1 branch
BranchTrueFalseTotal
if $preamble 0 4 4
144  
145 4 foreach my $part ($self->parts('ACTIVE'))
146 { # boundaries start with \n
147 8 ▶ if(!@lines) { ; }
Branch: 2 branches
BranchTrueFalseTotal
if (not @lines) { } 4 4 8
elsif ($lines[-1] =~ /\n$/) { } 4 0 4
148 4 elsif($lines[-1] =~ m/\n$/) { push @lines, "\n" }
149 0 else { $lines[-1] .= "\n" }
150 8 push @lines, "--$boundary\n", $part->lines;
151 }
152  
153 4 ▶ if(!@lines) { ; }
Branch: 2 branches
BranchTrueFalseTotal
if (not @lines) { } 0 4 4
elsif ($lines[-1] =~ /\n$/) { } 4 0 4
154 4 elsif($lines[-1] =~ m/\n$/) { push @lines, "\n" }
155 0 else { $lines[-1] .= "\n" }
156 4 push @lines, "--$boundary--";
157  
158 4 ▶ if(my $epilogue = $self->epilogue)
Branch: 1 branch
BranchTrueFalseTotal
if (my $epilogue = $self->epilogue) 0 4 4
159 0 { $lines[-1] .= "\n";
160 0 push @lines, $epilogue->lines;
161 }
162  
163 4 ▶ wantarray ? @lines : \@lines;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 4 0 4
164 }
165  
166 sub file() # It may be possible to speed-improve the next
167 0 ▶{ my $self = shift; # code, which first produces a full print of
Subroutine file: not called CC=1 SCAR=6.9
Pod documented
168 0 my $text; # the message in memory...
169 0 my $dump = Mail::Box::FastScalar->new(\$text);
170 0 $self->print($dump);
171 0 $dump->seek(0,0);
172 0 $dump;
173 }
174  
175 sub print(;$)
176 8 ▶{ my $self = shift;
Subroutine print: called CC=11 SCAR=27.0
Pod documented
177 8 ▶ my $out = shift || select;
Condition33%1/3
shift() || select()
l!l&&r!l&&!r
800
MC/DC0%0/2
shift() || select()
shift() select()
Truth table33%1/3
A || B
A= shift()B= select()
ABresult
1X1
011
000
178  
179 8 my $boundary = $self->boundary;
180 8 my $count = 0;
181 8 ▶ if(my $preamble = $self->preamble)
Branch: 1 branch
BranchTrueFalseTotal
if (my $preamble = $self->preamble) 2 6 8
182 2 { $preamble->print($out);
183 2 $count++;
184 }
185  
186 8 ▶ if(ref $out eq 'GLOB')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $out eq 'GLOB') { } 0 8 8
187 0 { foreach my $part ($self->parts('ACTIVE'))
188 0 ▶ { print $out "\n" if $count++;
Branch: 1 branch
BranchTrueFalseTotal
if $count++ 0 0 0
189 0 print $out "--$boundary\n";
190 0 $part->print($out);
191 }
192 0 ▶ print $out "\n" if $count++;
Branch: 1 branch
BranchTrueFalseTotal
if $count++ 0 0 0
193 0 print $out "--$boundary--";
194 }
195 else
196 8 { foreach my $part ($self->parts('ACTIVE'))
197 13 ▶ { $out->print("\n") if $count++;
Branch: 1 branch
BranchTrueFalseTotal
if $count++ 9 4 13
198 13 $out->print("--$boundary\n");
199 13 $part->print($out);
200 }
201 8 ▶ $out->print("\n") if $count++;
Branch: 1 branch
BranchTrueFalseTotal
if $count++ 6 2 8
202 8 $out->print("--$boundary--");
203 }
204  
205 8 ▶ if(my $epilogue = $self->epilogue)
Branch: 1 branch
BranchTrueFalseTotal
if (my $epilogue = $self->epilogue) 2 6 8
206 2 { $out->print("\n");
207 2 $epilogue->print($out);
208 }
209  
210 8 $self;
211 }
212  
213  
214 sub foreachLine($)
215 0 ▶{ my ($self, $code) = @_;
Subroutine foreachLine: not called CC=1 SCAR=6.9
Pod documented
216 0 $self->log(ERROR => "You cannot use foreachLine on a multipart");
217 0 confess;
218 }
219  
220 sub check()
221 0 ▶{ my $self = shift;
Subroutine check: not called CC=1 SCAR=6.9
Pod documented
222 0 ▶ $self->foreachComponent( sub {$_[1]->check} );
Subroutine __ANON__: not called CC=1 SCAR=6.9
223 }
224  
225 sub encode(@)
226 0 ▶{ my ($self, %args) = @_;
Subroutine encode: not called CC=1 SCAR=6.9
Pod documented
227 0 ▶ $self->foreachComponent( sub {$_[1]->encode(%args)} );
Subroutine __ANON__: not called CC=1 SCAR=6.9
228 }
229  
230 sub encoded()
231 20 ▶{ my $self = shift;
Subroutine encoded: called CC=1 SCAR=0.0
Pod documented
232 20 ▶ $self->foreachComponent( sub {$_[1]->encoded} );
Subroutine __ANON__: called CC=1 SCAR=0.0
233 }
234  
235 sub read($$$$)
236 7 ▶{ my ($self, $parser, $head, $bodytype) = @_;
Subroutine read: called CC=16 SCAR=28.7
Pod documented
237  
238 7 my $boundary = $self->boundary;
239  
240 7 $parser->pushSeparator("--$boundary");
241 7 my @msgopts = $self->logSettings;
242  
243 7 my $te;
244 7 ▶ $te = lc $1
Branch: 1 branch
BranchTrueFalseTotal
if ($head->get("Content-Transfer-Encoding") || "") =~ /(\w+)/ 1 6 7
Condition100%2/2
$head->get('Content-Transfer-Encoding') || ''
l!l
16
MC/DC100%1/1
$head->get('Content-Transfer-Encoding') || ''
$head->get('Content-Transfer-Encoding')
Truth table100%2/2
A
A= $head->get('Content-Transfer-Encoding')
Aresult
11
00
245 if +($head->get('Content-Transfer-Encoding') || '') =~ m/(\w+)/;
246
247 7 my @sloppyopts =
248 ( mime_type => 'text/plain'
249 , transfer_encoding => $te
250 );
251  
252 # Get preamble.
253 7 my $headtype = ref $head;
254  
255 7 my $begin = $parser->filePosition;
256 7 my $preamble = Mail::Message::Body::Lines->new(@msgopts, @sloppyopts)
257 ->read($parser, $head);
258  
259 7 ▶ $preamble->nrLines
Branch: 1 branch
BranchTrueFalseTotal
$preamble->nrLines or undef $preamble 6 1 7
260 or undef $preamble;
261  
262 7 ▶ $self->{MMBM_preamble} = $preamble
Branch: 1 branch
BranchTrueFalseTotal
if defined $preamble 1 6 7
263 if defined $preamble;
264  
265 # Get the parts.
266  
267 7 my ($has_epilogue, @parts);
268 7 ▶ while(my $sep = $parser->readSeparator)
Branch: 1 branch
BranchTrueFalseTotal
if (my $sep = $parser->readSeparator) 20 0 20
269 20 ▶ { if($sep =~ m/--\Q$boundary\E--[ \t]*\n?/)
Branch: 1 branch
BranchTrueFalseTotal
if ($sep =~ /--\Q$boundary\E--[ \t]*\n?/) 7 13 20
270 { # Per RFC 2046, a CRLF after the close-delimiter marks the presence
271 # of an epilogue. Preserve the epilogue, even if empty, so that the
272 # printed multipart body will also have the CRLF.
273 # This, however, is complicated w.r.t. mbox folders.
274 7 $has_epilogue = $sep =~ /\n/;
275 7 last;
276 }
277  
278 13 my $part = Mail::Message::Part->new
279 ( @msgopts
280 , container => $self
281 );
282  
283 13 ▶ last unless $part->readFromParser($parser, $bodytype);
Branch: 1 branch
BranchTrueFalseTotal
unless $part->readFromParser($parser, $bodytype) 0 13 13
284 13 ▶ push @parts, $part
Branch: 1 branch
BranchTrueFalseTotal
if $part->head->names or $part->body->size 13 0 13
Condition33%1/3
$part->head->names or $part->body->size
l!l&&r!l&&!r
1300
MC/DC0%0/2
$part->head->names or $part->body->size
$part->head->names $part->body->size
Truth table33%1/3
A or B
A= $part->head->namesB= $part->body->size
ABresult
1X1
011
000
285 if $part->head->names || $part->body->size;
286 }
287 7 $self->{MMBM_parts} = \@parts;
288  
289 # Get epilogue
290  
291 7 $parser->popSeparator;
292 7 my $epilogue = Mail::Message::Body::Lines->new(@msgopts, @sloppyopts)
293 ->read($parser, $head);
294  
295 7 ▶ my $end = defined $epilogue ? ($epilogue->fileLocation)[1]
Branch: 3 branches
BranchTrueFalseTotal
defined $epilogue ? : 7 0 7
@parts ? : 0 0 0
defined $preamble ? : 0 0 0
296 : @parts ? ($parts[-1]->body->fileLocation)[1]
297 : defined $preamble ? ($preamble->fileLocation)[1]
298 : $begin;
299 7 $self->fileLocation($begin, $end);
300  
301 7 ▶ $has_epilogue || $epilogue->nrLines
Branch: 1 branch
BranchTrueFalseTotal
$has_epilogue or $epilogue->nrLines or undef $epilogue 1 6 7
Condition66%2/3
$has_epilogue or $epilogue->nrLines
l!l&&r!l&&!r
601
MC/DC50%1/2
$has_epilogue or $epilogue->nrLines
$has_epilogue $epilogue->nrLines
Truth table66%2/3
A or B
A= $has_epilogueB= $epilogue->nrLines
ABresult
1X1
011
000
302 or undef $epilogue;
303  
304 7 ▶ $self->{MMBM_epilogue} = $epilogue
Branch: 1 branch
BranchTrueFalseTotal
if defined $epilogue 6 1 7
305 if defined $epilogue;
306  
307 7 $self;
308 }
309  
310 #------------------------------------------
311  
312  
313 sub foreachComponent($)
314 20 ▶{ my ($self, $code) = @_;
Subroutine foreachComponent: called CC=10 SCAR=23.0
Pod documented
315 20 my $changes = 0;
316  
317 20 my $new_preamble;
318 20 ▶ if(my $preamble = $self->preamble)
Branch: 1 branch
BranchTrueFalseTotal
if (my $preamble = $self->preamble) 2 18 20
319 2 { $new_preamble = $code->($self, $preamble);
320 2 ▶ $changes++ unless $preamble == $new_preamble;
Branch: 1 branch
BranchTrueFalseTotal
unless $preamble == $new_preamble 1 1 2
321 }
322  
323 20 my $new_epilogue;
324 20 ▶ if(my $epilogue = $self->epilogue)
Branch: 1 branch
BranchTrueFalseTotal
if (my $epilogue = $self->epilogue) 2 18 20
325 2 { $new_epilogue = $code->($self, $epilogue);
326 2 ▶ $changes++ unless $epilogue == $new_epilogue;
Branch: 1 branch
BranchTrueFalseTotal
unless $epilogue == $new_epilogue 1 1 2
327 }
328  
329 20 my @new_bodies;
330 20 foreach my $part ($self->parts('ACTIVE'))
331 32 { my $part_body = $part->body;
332 32 my $new_body = $code->($self, $part_body);
333  
334 32 ▶ $changes++ if $new_body != $part_body;
Branch: 1 branch
BranchTrueFalseTotal
if $new_body != $part_body 13 19 32
335 32 push @new_bodies, [$part, $new_body];
336 }
337  
338 20 ▶ return $self unless $changes;
Branch: 1 branch
BranchTrueFalseTotal
unless $changes 10 10 20
339  
340 10 my @new_parts;
341 10 foreach (@new_bodies)
342 21 { my ($part, $body) = @$_;
343 21 my $new_part = Mail::Message::Part->new
344 ( head => $part->head->clone,
345 container => undef
346 );
347 21 $new_part->body($body);
348 21 push @new_parts, $new_part;
349 }
350  
351 10 my $constructed = (ref $self)->new
352 ( preamble => $new_preamble
353 , parts => \@new_parts
354 , epilogue => $new_epilogue
355 , based_on => $self
356 );
357  
358 $_->container($constructed)
359 10 foreach @new_parts;
360  
361 10 $constructed;
362 }
363  
364  
365 sub attach(@)
366 2 ▶{ my $self = shift;
Subroutine attach: called CC=1 SCAR=0.0
Pod documented
367 2 my $new = ref($self)->new
368 ( based_on => $self
369 , parts => [$self->parts, @_]
370 );
371 }
372  
373  
374 sub stripSignature(@)
375 1 ▶{ my $self = shift;
Subroutine stripSignature: called CC=2 SCAR=7.0
Pod documented
376  
377 1 my @allparts = $self->parts;
378 1 my @parts = grep {! $_->body->mimeType->isSignature} @allparts;
379  
380 1 ▶ @allparts==@parts ? $self
Branch: 1 branch
BranchTrueFalseTotal
@allparts == @parts ? : 0 1 1
381 : (ref $self)->new(based_on => $self, parts => \@parts);
382 }
383  
384 #------------------------------------------
385  
386  
387 106 ▶sub preamble() {shift->{MMBM_preamble}}
Subroutine preamble: called CC=1 SCAR=0.0
Pod documented
388  
389  
390 110 ▶sub epilogue() {shift->{MMBM_epilogue}}
Subroutine epilogue: called CC=1 SCAR=0.0
Pod documented
391  
392  
393 sub parts(;$)
394 161 ▶{ my $self = shift;
Subroutine parts: called CC=7 SCAR=23.0
Pod documented
395 161 ▶ return @{$self->{MMBM_parts}} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 67 94 161
396  
397 94 my $what = shift;
398 94 my @parts = @{$self->{MMBM_parts}};
399  
400 0 ▶ $what eq 'RECURSE' ? (map {$_->parts('RECURSE')} @parts)
Branch: 2 branches
BranchTrueFalseTotal
$what eq 'ALL' ? : 0 94 94
$what eq 'DELETED' ? : 0 94 94
401 : $what eq 'ALL' ? @parts
402 0 ▶ : $what eq 'DELETED' ? (grep {$_->isDeleted} @parts)
Branch: 1 branch
BranchTrueFalseTotal
$what eq 'ACTIVE' ? : 94 0 94
403 160 ▶ : $what eq 'ACTIVE' ? (grep {not $_->isDeleted} @parts)
Branch: 1 branch
BranchTrueFalseTotal
ref $what eq 'CODE' ? : 0 0 0
404 94 ▶ : ref $what eq 'CODE'? (grep {$what->($_)} @parts)
Branch: 1 branch
BranchTrueFalseTotal
$what eq 'RECURSE' ? : 0 94 94
405 : ($self->log(ERROR => "Unknown criterium $what to select parts."), return ());
406 }
407  
408  
409 13 ▶sub part($) { shift->{MMBM_parts}[shift] }
Subroutine part: called CC=1 SCAR=0.0
Pod documented
410  
411 sub partNumberOf($)
412 8 ▶{ my ($self, $part) = @_;
Subroutine partNumberOf: called CC=5 SCAR=17.3
Pod documented
413 8 my $msg = $self->message;
414 8 ▶ unless($msg)
Branch: 1 branch
BranchTrueFalseTotal
unless ($msg) 0 8 8
415 0 { $self->log(ERROR => 'multipart is not connected');
416 0 return 'ERROR';
417 }
418  
419 8 ▶ my $base = $msg->isa('Mail::Message::Part') ? $msg->partNumber.'.' : '';
Branch: 1 branch
BranchTrueFalseTotal
$msg->isa('Mail::Message::Part') ? : 2 6 8
420  
421 8 my @parts = $self->parts('ACTIVE');
422 8 foreach my $partnr (0..@parts)
423 15 ▶ { return $base.($partnr+1)
Branch: 1 branch
BranchTrueFalseTotal
if $parts[$partnr] == $part 8 7 15
424 if $parts[$partnr] == $part;
425 }
426 0 $self->log(ERROR => 'multipart is not found or not active');
427 0 'ERROR';
428 }
429  
430  
431 sub boundary(;$)
432 114 ▶{ my $self = shift;
Subroutine boundary: called CC=5 SCAR=16.2
Pod documented
433 114 my $mime = $self->type;
434  
435 114 ▶ unless(@_)
Branch: 1 branch
BranchTrueFalseTotal
unless (@_) 72 42 114
436 72 { my $boundary = $mime->attribute('boundary');
437 72 ▶ return $boundary if defined $boundary;
Branch: 1 branch
BranchTrueFalseTotal
if defined $boundary 72 0 72
438 }
439  
440 42 ▶ my $boundary = @_ && defined $_[0] ? (shift) : "boundary-".int rand(1000000);
Branch: 1 branch
BranchTrueFalseTotal
@_ && defined $_[0] ? : 26 16 42
Condition66%2/3
@_ and defined $_[0]
!ll&&!rl&&r
01626
MC/DC50%1/2
@_ and defined $_[0]
@_ defined $_[0]
Truth table66%2/3
A and B
A= @_B= defined $_[0]
ABresult
0X0
100
111
441 42 $self->type->attribute(boundary => $boundary);
442 }
443  
444 sub endsOnNewline() { 1 }
445  
446 0 ▶sub toplevel() { my $msg = shift->message; $msg ? $msg->toplevel : undef}
Subroutine toplevel: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$msg ? : 0 0 0
447  
448 #-------------------------------------------
449  
450  
451 34 1;
« Box/FastScalar.pm ↑ Summary Message/Head/Partial.pm »