Message/Field/Fast.pm

filter: Statementstmt 93.4% 43 / 46 Branchbran 83.3% 15 / 18 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 92.3% 12 / 13 Podpod 100% 9 / 9 totaltotal 87.9% 80 / 91 CC 11 SCAR 9.9
CC
11
Cov
88%
new
5.1
print
3.4
foldedBody
3.0
CRAP 2.7
« Message/Body/String.pm ↑ Summary Message/Body/Nested.pm »
1 # Copyrights 2001-2022 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::Field::Fast;
10 40 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 40 $VERSION = '3.012';
12  
13 40 ▶use base 'Mail::Message::Field';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 #------------------------------------------
20 #
21 # The DATA is stored as: [ NAME, FOLDED-BODY ]
22 # The body is kept in a folded fashion, where each line starts with
23 # a single blank.
24  
25  
26 sub new($;$@)
27 785 ▶{ my $class = shift;
Subroutine new: called CC=5 SCAR=16.2
Pod documented
28  
29 785 ▶ my ($name, $body) = $class->consume(@_==1 ? (shift) : (shift, shift));
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 8 777 785
30 785 ▶ return () unless defined $body;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $body 0 785 785
31  
32 785 my $self = bless [$name, $body], $class;
33  
34 # Attributes
35 785 ▶ $self->comment(shift) if @_==1; # one attribute line
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 1 784 785
36 785 ▶ $self->attribute(shift, shift) while @_ > 1; # attribute pairs
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 and do { $self->attribute(shift(), shift()) } 0 785 785
37  
38 785 $self;
39 }
40  
41 sub clone()
42 1355 ▶{ my $self = shift;
Subroutine clone: called CC=1 SCAR=0.0
Pod documented
43 1355 bless [ @$self ], ref $self;
44 }
45  
46 sub length()
47 0 ▶{ my $self = shift;
Subroutine length: not called CC=1 SCAR=6.9
Pod documented
48 0 length($self->[0]) + 1 + length($self->[1]);
49 }
50  
51 1551 ▶sub name() { lc shift->[0] }
Subroutine name: called CC=1 SCAR=0.0
Pod documented
52 16 ▶sub Name() { shift->[0] }
Subroutine Name: called CC=1 SCAR=0.0
Pod documented
53  
54 sub folded()
55 249 ▶{ my $self = shift;
Subroutine folded: called CC=2 SCAR=6.9
Pod documented
56 249 ▶ return $self->[0].':'.$self->[1]
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 197 52 249
57 unless wantarray;
58  
59 52 my @lines = $self->foldedBody;
60 52 my $first = $self->[0]. ':'. shift @lines;
61 52 ($first, @lines);
62 }
63  
64 sub unfoldedBody($;@)
65 1658 ▶{ my $self = shift;
Subroutine unfoldedBody: called CC=2 SCAR=6.9
Pod documented
66  
67 1658 ▶ $self->[1] = $self->fold($self->[0], @_)
Branch: 1 branch
BranchTrueFalseTotal
if @_ 114 1544 1658
68 if @_;
69  
70 1658 $self->unfold($self->[1]);
71 }
72  
73 sub foldedBody($)
74 194 ▶{ my ($self, $body) = @_;
Subroutine foldedBody: called CC=3 SCAR=11.0
Pod documented
75 194 ▶ if(@_==2) { $self->[1] = $body }
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 2) { } 4 190 194
76 190 else { $body = $self->[1] }
77
78 194 ▶ wantarray ? (split m/^/, $body) : $body;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 149 45 194
79 }
80  
81 # For performance reasons only
82 sub print(;$)
83 107 ▶{ my $self = shift;
Subroutine print: called CC=3 SCAR=12.3
Pod documented
84 107 ▶ my $fh = shift || select;
Condition33%1/3
shift() || select()
l!l&&r!l&&!r
10700
MC/DC0%0/2
shift() || select()
shift() select()
Truth table33%1/3
A || B
A= shift()B= select()
ABresult
1X1
011
000
85 107 ▶ if(ref $fh eq 'GLOB') { print $fh $self->[0].':'.$self->[1] }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $fh eq 'GLOB') { } 0 107 107
86 107 else { $fh->print($self->[0].':'.$self->[1]) }
87 107 $self;
88 }
89  
90 40 1;
« Message/Body/String.pm ↑ Summary Message/Body/Nested.pm »