Message/Field/Fast.pm

filter: Statementstmt 95.8% 46 / 48 Branchbran 87.5% 14 / 16 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 92.8% 13 / 14 Podpod 100% 9 / 9 totaltotal 90.2% 83 / 92 CC 10 SCAR 9.0
CC
10
Cov
91%
new
5.1
foldedBody
3.0
print
2.1
CRAP 2.5
« Message/Convert/MimeEntity.pm ↑ Summary Message/TransferEnc/Base64.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::Field::Fast;{
13 45 our $VERSION = '4.05';
14 }
15  
16 45 ▶use parent 'Mail::Message::Field';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 45 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 45 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 45 ▶use Log::Report 'mail-message', import => [ qw// ];
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 45 ▶use Scalar::Util qw/blessed/;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 #--------------------
26  
27 # The DATA is stored as: [ NAME, FOLDED-BODY ]
28 # The body is kept in a folded fashion, where each line starts with
29 # a single blank.
30  
31  
32 sub new($;$@)
33 1959 ▶{ my $class = shift;
Subroutine new: called CC=5 SCAR=16.2
Pod documented
34  
35 1959 ▶ my ($name, $body) = $class->consume(@_==1 ? (shift) : (shift, shift));
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 9 1950 1959
36 1959 ▶ defined $body or return ();
Branch: 1 branch
BranchTrueFalseTotal
defined $body or return () 1959 0 1959
37  
38 1959 my $self = bless +[$name, $body], $class;
39  
40 # Attributes
41 1959 ▶ $self->comment(shift) if @_==1; # one attribute line
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 1 1958 1959
42 1959 ▶ $self->attribute(shift, shift) while @_ > 1; # attribute pairs
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 and do { $self->attribute(shift(), shift()) } 0 1959 1959
43 1959 $self;
44 }
45  
46 sub clone()
47 1664 ▶{ my $self = shift;
Subroutine clone: called CC=1 SCAR=0.0
Pod documented
48 1664 bless +[ @$self ], ref $self;
49 }
50  
51 sub length()
52 0 ▶{ my $self = shift;
Subroutine length: not called CC=1 SCAR=6.9
Pod documented
53 0 length($self->[0]) + 1 + length($self->[1]);
54 }
55  
56 5252 ▶sub name() { lc shift->[0] }
Subroutine name: called CC=1 SCAR=0.0
Pod documented
57 16 ▶sub Name() { $_[0]->[0] }
Subroutine Name: called CC=1 SCAR=0.0
Pod documented
58  
59 sub folded()
60 276 ▶{ my $self = shift;
Subroutine folded: called CC=2 SCAR=6.9
Pod documented
61 276 ▶ wantarray or return $self->[0] .':'. $self->[1];
Branch: 1 branch
BranchTrueFalseTotal
wantarray or return $self->[0] . ':' . $self->[1] 52 224 276
62  
63 52 my @lines = $self->foldedBody;
64 52 my $first = $self->[0]. ':'. shift @lines;
65 52 ($first, @lines);
66 }
67  
68 sub unfoldedBody($;@)
69 2858 ▶{ my $self = shift;
Subroutine unfoldedBody: called CC=2 SCAR=6.9
Pod documented
70  
71 2858 ▶ $self->[1] = $self->fold($self->[0], @_)
Branch: 1 branch
BranchTrueFalseTotal
if @_ 153 2705 2858
72 if @_;
73  
74 2858 $self->unfold($self->[1]);
75 }
76  
77 sub foldedBody($)
78 219 ▶{ my ($self, $body) = @_;
Subroutine foldedBody: called CC=3 SCAR=11.0
Pod documented
79 219 ▶ if(@_==2) { $self->[1] = $body }
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 2) { } 4 215 219
80 215 else { $body = $self->[1] }
81  
82 219 ▶ wantarray ? (split m/^/, $body) : $body;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 158 61 219
83 }
84  
85 # For performance reasons only
86 sub print(;$)
87 131 ▶{ my $self = shift;
Subroutine print: called CC=2 SCAR=7.4
Pod documented
88 131 ▶ my $fh = shift || select;
Condition33%1/3
shift() || select()
l!l&&r!l&&!r
13100
MC/DC0%0/2
shift() || select()
shift() select()
Truth table33%1/3
A || B
A= shift()B= select()
ABresult
1X1
011
000
89 131 $fh->print($self->[0].':'.$self->[1]);
90 131 $self;
91 }
92  
93 45 1;
« Message/Convert/MimeEntity.pm ↑ Summary Message/TransferEnc/Base64.pm »