Message/Field/Flex.pm

filter: Statementstmt 91.8% 45 / 49 Branchbran 81.8% 18 / 22 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 84.6% 11 / 13 Podpod 88.8% 8 / 9 totaltotal 83.5% 86 / 103 CC 14 SCAR 14.2
CC
14
Cov
86%
new
8.9
init
3.0
foldedBody
3.0
CRAP 4.1
« Message/Field/AddrGroup.pm ↑ Summary Message/Field/Unstructured.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::Flex;{
13 3 our $VERSION = '4.05';
14 }
15  
16 3 ▶use parent 'Mail::Message::Field';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 3 ▶use Log::Report 'mail-message', import => [ qw// ];
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 #--------------------
24  
25 sub new($;$$@)
26 18 ▶{ my $class = shift;
Subroutine new: called CC=8 SCAR=21.8
Pod documented
27 my $args
28 = @_ <= 2 || ! ref $_[-1] ? {}
29 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
30 : pop @_;
31  
32 18 ▶ my ($name, $body) = $class->consume(@_==1 ? (shift) : (shift, shift));
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 6 12 18
33 18 ▶ defined $body or return ();
Branch: 1 branch
BranchTrueFalseTotal
defined $body or return () 18 0 18
34  
35 # Attributes preferably stored in array to protect order.
36 18 my $attr = $args->{attributes};
37 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
38 18 push @$attr, @_;
39  
40 18 $class->SUPER::new(%$args, name => $name, body => $body, attributes => $attr);
41 }
42  
43 sub init($)
44 18 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=3 SCAR=11.0
Pod undocumented
45  
46 18 @$self{ qw/MMFF_name MMFF_body/ } = @$args{ qw/name body/ };
47 18 ▶ $self->comment($args->{comment}) if exists $args->{comment};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args->{"comment"} 1 17 18
48  
49 18 my $attr = $args->{attributes};
50 18 ▶ $self->attribute(shift @$attr, shift @$attr) while @$attr;
Branch: 1 branch
BranchTrueFalseTotal
@$attr and do { $self->attribute(shift @$attr, shift @$attr) } 0 18 18
51  
52 18 $self;
53 }
54  
55 sub clone()
56 0 ▶{ my $self = shift;
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
57 0 (ref $self)->new($self->Name, $self->body);
58 }
59  
60 sub length()
61 0 ▶{ my $self = shift;
Subroutine length: not called CC=1 SCAR=6.9
Pod documented
62 0 length($self->{MMFF_name}) + 1 + length($self->{MMFF_body});
63 }
64  
65 27 ▶sub name() { lc($_[0]->{MMFF_name}) }
Subroutine name: called CC=1 SCAR=0.0
Pod documented
66  
67 5 ▶sub Name() { $_[0]->{MMFF_name} }
Subroutine Name: called CC=1 SCAR=0.0
Pod documented
68  
69 sub folded(;$)
70 8 ▶{ my $self = shift;
Subroutine folded: called CC=2 SCAR=6.9
Pod documented
71  
72 wantarray
73 8 ▶ or return $self->{MMFF_name}.':'.$self->{MMFF_body};
Branch: 1 branch
BranchTrueFalseTotal
wantarray or return $self->{"MMFF_name"} . ':' . $self->{"MMFF_body"} 2 6 8
74  
75 2 my @lines = $self->foldedBody;
76 2 my $first = $self->{MMFF_name}. ':'. shift @lines;
77 2 ($first, @lines);
78 }
79  
80 sub unfoldedBody($;@)
81 39 ▶{ my $self = shift;
Subroutine unfoldedBody: called CC=2 SCAR=6.9
Pod documented
82 39 ▶ $self->{MMFF_body} = $self->fold($self->{MMFF_name}, @_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 2 37 39
83 39 $self->unfold($self->{MMFF_body});
84 }
85  
86 sub foldedBody($)
87 13 ▶{ my ($self, $body) = @_;
Subroutine foldedBody: called CC=3 SCAR=11.0
Pod documented
88 13 ▶ if(@_==2) { $self->{MMFF_body} = $body }
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 2) { } 3 10 13
89 10 else { $body = $self->{MMFF_body} }
90  
91 13 ▶ wantarray ? (split /^/, $body) : $body;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 3 10 13
92 }
93  
94 3 1;
« Message/Field/AddrGroup.pm ↑ Summary Message/Field/Unstructured.pm »