Message/Field/Flex.pm

filter: Statementstmt 92.1% 47 / 51 Branchbran 81.8% 18 / 22 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 85.7% 12 / 14 Podpod 88.8% 8 / 9 totaltotal 83.9% 89 / 106 SCAR 26.8
CC
14
Cov
86%
new
8.9
init
3.0
foldedBody
3.0
CRAP 14.5
« Message/Construct/Bounce.pm ↑ Summary Message/Field/URIs.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::Field::Flex;
10 3 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 $VERSION = '3.013';
12  
13 3 ▶use base 'Mail::Message::Field';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21 sub new($;$$@)
22 18 ▶{ my $class = shift;
Subroutine new: called CC=8 SCAR=21.8
Pod documented
23 my $args = @_ <= 2 || ! ref $_[-1] ? {}
24 18 ▶ : ref $_[-1] eq 'ARRAY' ? { @{pop @_} }
Branch: 2 branches
BranchTrueFalseTotal
@_ <= 2 || !ref($_[-1]) ? : 17 1 18
ref $_[-1] eq 'ARRAY' ? : 1 0 1
Condition66%2/3
@_ <= 2 or not ref $_[-1]
l!l&&r!l&&!r
1701
MC/DC50%1/2
@_ <= 2 or not ref $_[-1]
@_ <= 2 not ref $_[-1]
Truth table66%2/3
A or not(B)
A= @_ <= 2B= not ref $_[-1]
ABresult
1X1
011
000
25 : pop @_;
26  
27 18 ▶ my ($name, $body) = $class->consume(@_==1 ? (shift) : (shift, shift));
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 6 12 18
28 18 ▶ return () unless defined $body;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $body 0 18 18
29  
30 # Attributes preferably stored in array to protect order.
31 18 my $attr = $args->{attributes};
32 18 ▶ $attr = [ %$attr ] if defined $attr && ref $attr eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if defined $attr and ref $attr eq "HASH" 0 18 18
Condition33%1/3
defined $attr and ref $attr eq "HASH"
!ll&&!rl&&r
1800
MC/DC0%0/2
defined $attr and ref $attr eq "HASH"
defined $attr ref $attr eq "HASH"
Truth table33%1/3
A and B
A= defined $attrB= ref $attr eq "HASH"
ABresult
0X0
100
111
33 18 push @$attr, @_;
34  
35 18 $class->SUPER::new(%$args, name => $name, body => $body,
36 attributes => $attr);
37 }
38  
39 sub init($)
40 18 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=3 SCAR=11.0
Pod undocumented
41  
42 18 @$self{ qw/MMFF_name MMFF_body/ } = @$args{ qw/name body/ };
43  
44 $self->comment($args->{comment})
45 18 ▶ if exists $args->{comment};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args->{"comment"} 1 17 18
46  
47 18 my $attr = $args->{attributes};
48 18 ▶ $self->attribute(shift @$attr, shift @$attr)
Branch: 1 branch
BranchTrueFalseTotal
@$attr and do { $self->attribute(shift @$attr, shift @$attr) } 0 18 18
49 while @$attr;
50  
51 18 $self;
52 }
53  
54 #------------------------------------------
55  
56 sub clone()
57 0 ▶{ my $self = shift;
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
58 0 (ref $self)->new($self->Name, $self->body);
59 }
60  
61 #------------------------------------------
62  
63 sub length()
64 0 ▶{ my $self = shift;
Subroutine length: not called CC=1 SCAR=6.9
Pod documented
65 0 length($self->{MMFF_name}) + 1 + length($self->{MMFF_body});
66 }
67  
68 #------------------------------------------
69  
70 27 ▶sub name() { lc shift->{MMFF_name}}
Subroutine name: called CC=1 SCAR=0.0
Pod documented
71  
72 #------------------------------------------
73  
74 5 ▶sub Name() { shift->{MMFF_name}}
Subroutine Name: called CC=1 SCAR=0.0
Pod documented
75  
76 #------------------------------------------
77  
78 sub folded(;$)
79 8 ▶{ my $self = shift;
Subroutine folded: called CC=2 SCAR=6.9
Pod documented
80 return $self->{MMFF_name}.':'.$self->{MMFF_body}
81 8 ▶ unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 6 2 8
82  
83 2 my @lines = $self->foldedBody;
84 2 my $first = $self->{MMFF_name}. ':'. shift @lines;
85 2 ($first, @lines);
86 }
87  
88 #------------------------------------------
89  
90 sub unfoldedBody($;@)
91 38 ▶{ my $self = shift;
Subroutine unfoldedBody: called CC=2 SCAR=6.9
Pod documented
92 38 ▶ $self->{MMFF_body} = $self->fold($self->{MMFF_name}, @_)
Branch: 1 branch
BranchTrueFalseTotal
if @_ 2 36 38
93 if @_;
94  
95 38 $self->unfold($self->{MMFF_body});
96 }
97  
98 #------------------------------------------
99  
100 sub foldedBody($)
101 13 ▶{ my ($self, $body) = @_;
Subroutine foldedBody: called CC=3 SCAR=11.0
Pod documented
102 13 ▶ if(@_==2) { $self->{MMFF_body} = $body }
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 2) { } 3 10 13
103 10 else { $body = $self->{MMFF_body} }
104  
105 13 ▶ wantarray ? (split /^/, $body) : $body;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 3 10 13
106 }
107  
108 #------------------------------------------
109  
110 3 1;
« Message/Construct/Bounce.pm ↑ Summary Message/Field/URIs.pm »