Message/Construct/Text.pm

filter: Statementstmt 100% 43 / 43 Branchbran 70.0% 14 / 20 Conditioncond 57.1% 4 / 7 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 8 / 8 Podpod 100% 4 / 4 totaltotal 86.0% 74 / 86 CC 15 SCAR 21.8
CC
15
Cov
87%
printStructure
14.0
string
2.1
lines
2.0
CRAP 8.9
« Message/Head/Complete.pm ↑ Summary Message/Field/Addresses.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;{
13 5 our $VERSION = '4.05';
14 }
15  
16  
17 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 5 ▶use Log::Report 'mail-message', import => [ qw// ];
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 5 ▶use IO::Lines ();
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 #--------------------
25  
26 sub string()
27 5 ▶{ my $self = shift;
Subroutine string: called CC=2 SCAR=7.2
Pod documented
28 5 ▶ $self->head->string . $self->body->string . ($self->endsOnNewline ? '' : "\n");
Branch: 1 branch
BranchTrueFalseTotal
$self->endsOnNewline ? : 5 0 5
29 }
30  
31  
32 sub lines()
33 8 ▶{ my $self = shift;
Subroutine lines: called CC=2 SCAR=7.0
Pod documented
34 8 my @lines;
35 8 my $file = IO::Lines->new(\@lines);
36 8 $self->print($file);
37 8 ▶ wantarray ? @lines : \@lines;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 8 0 8
38 }
39  
40  
41 sub file()
42 2 ▶{ my $self = shift;
Subroutine file: called CC=1 SCAR=0.0
Pod documented
43 2 my $file = IO::Lines->new;
44 2 $self->print($file);
45 2 $file->seek(0, 0);
46 2 $file;
47 }
48  
49  
50 sub printStructure(;$$)
51 6 ▶{ my $self = shift;
Subroutine printStructure: called CC=13 SCAR=26.4
Pod documented
52  
53 6 ▶ my $indent
Branch: 2 branches
BranchTrueFalseTotal
@_ == 2 ? : 5 1 6
defined $_[0] && !ref($_[0]) ? : 0 1 1
Condition33%1/3
defined $_[0] and not ref $_[0]
!ll&&!rl&&r
010
MC/DC0%0/2
defined $_[0] and not ref $_[0]
defined $_[0] not ref $_[0]
Truth table33%1/3
A and not(B)
A= defined $_[0]B= not ref $_[0]
ABresult
0X0
100
111
54 = @_==2 ? pop
55 : defined $_[0] && !ref $_[0] ? shift
56 : '';
57  
58 6 ▶ my $fh = @_ ? shift : select;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 6 0 6
59  
60 6 my $buffer; # only filled if filehandle==undef
61 6 ▶ open $fh, '>:raw', \$buffer unless defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fh 0 6 6
62  
63 6 ▶ my $subject = $self->get('Subject') || '';
Condition100%2/2
$self->get('Subject') || ''
l!l
24
MC/DC100%1/1
$self->get('Subject') || ''
$self->get('Subject')
Truth table100%2/2
A
A= $self->get('Subject')
Aresult
11
00
64 6 ▶ $subject = ": $subject" if length $subject;
Branch: 1 branch
BranchTrueFalseTotal
if length $subject 2 4 6
65  
66 6 ▶ my $type = $self->get('Content-Type', 0) || '';
Condition50%1/2
$self->get('Content-Type', 0) || ''
l!l
60
MC/DC0%0/1
$self->get('Content-Type', 0) || ''
$self->get('Content-Type', 0)
Truth table50%1/2
A
A= $self->get('Content-Type', 0)
Aresult
11
00
67 6 my $size = $self->size;
68 6 ▶ my $deleted = $self->label('deleted') ? ', deleted' : '';
Branch: 1 branch
BranchTrueFalseTotal
$self->label('deleted') ? : 0 6 6
69  
70 6 my $text = "$indent$type$subject ($size bytes$deleted)\n";
71 6 $fh->print($text);
72  
73 6 my $body = $self->body;
74 my @parts
75 6 ▶ = $body->isNested ? ($body->nested)
Branch: 2 branches
BranchTrueFalseTotal
$body->isNested ? : 1 5 6
$body->isMultipart ? : 2 3 5
76 : $body->isMultipart ? $body->parts
77 : ();
78  
79 $_->printStructure($fh, $indent.' ')
80 6 for @parts;
81  
82 6 $buffer;
83 }
84  
85 #--------------------
86  
87 5 1;
« Message/Head/Complete.pm ↑ Summary Message/Field/Addresses.pm »