RFC2047/AddressList.pm

filter: Statementstmt 97.5% 40 / 41 Branchbran 83.3% 5 / 6 Conditioncond 55.5% 5 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 11 / 11 Podpod 100% 5 / 5 totaltotal 84.6% 66 / 78 SCAR 19.5
CC
7
Cov
89%
parse
6.2
format
2.1
BEGIN
1.0
CRAP 7.1
« RFC2047/Group.pm ↑ Summary RFC2047/Parser.pm »
1 package Email::MIME::RFC2047::AddressList;
2 4 $Email::MIME::RFC2047::AddressList::VERSION = '0.96';
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # ABSTRACT: Handling of MIME encoded address lists
7  
8 4 ▶use base qw(Email::MIME::RFC2047::Parser);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 ▶use Email::MIME::RFC2047::Decoder;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Email::MIME::RFC2047::Address;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub new {
14 22 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
15  
16 22 my $self = [ @_ ];
17  
18 22 return bless($self, $class);
19 }
20  
21 sub parse {
22 20 ▶ my ($class, $string, $decoder) = @_;
Subroutine parse: called CC=6 SCAR=18.3
Pod documented
23 20 ▶ my $string_ref = ref($string) ? $string : \$string;
Branch: 1 branch
BranchTrueFalseTotal
ref $string ? : 6 14 20
24 20 ▶ $decoder ||= Email::MIME::RFC2047::Decoder->new();
Condition66%2/3
$decoder ||= "Email::MIME::RFC2047::Decoder"->new
l!l&&r!l&&!r
6140
MC/DC0%0/2
$decoder ||= "Email::MIME::RFC2047::Decoder"->new
$decoder "Email::MIME::RFC2047::Decoder"->new
Truth table66%2/3
A ||= B
A= $decoderB= "Email::MIME::RFC2047::Decoder"->new
ABresult
1X1
011
000
25  
26 20 my @addresses;
27  
28 20 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$$string_ref =~ /\G,/cg and do { do { my $address = $class->_parse_item($string_ref, $decoder); CORE::push @addresses, $address } } 20 13 33
29 40 my $address = $class->_parse_item($string_ref, $decoder);
30 33 push(@addresses, $address);
31 } while ($$string_ref =~ /\G,/cg);
32  
33 13 ▶ if (!ref($string) && pos($string) < length($string)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $string and pos $string < length $string) 0 13 13
Condition66%2/3
not ref $string and pos $string < length $string
!ll&&!rl&&r
490
MC/DC0%0/2
not ref $string and pos $string < length $string
not ref $string pos $string < length $string
Truth table66%2/3
not(A) and B
A= not ref $stringB= pos $string < length $string
ABresult
0X0
100
111
34 0 return $class->_parse_error($string_ref);
35 }
36  
37 13 return $class->new(@addresses);
38 }
39  
40 sub _parse_item {
41 19 ▶ my ($class, $string_ref, $decoder) = @_;
Subroutine _parse_item: called CC=1 SCAR=0.0
42  
43 19 return Email::MIME::RFC2047::Address->parse(
44 $string_ref, $decoder
45 );
46 }
47  
48 sub items {
49 5 ▶ my $self = shift;
Subroutine items: called CC=1 SCAR=0.0
Pod documented
50  
51 5 return @$self;
52 }
53  
54 sub push {
55 13 ▶ my $self = shift;
Subroutine push: called CC=1 SCAR=0.0
Pod documented
56  
57 13 push(@$self, @_);
58  
59 13 return;
60 }
61  
62 sub format {
63 7 ▶ my ($self, $encoder) = @_;
Subroutine format: called CC=2 SCAR=7.4
Pod documented
64 7 ▶ $encoder ||= Email::MIME::RFC2047::Encoder->new();
Condition33%1/3
$encoder ||= "Email::MIME::RFC2047::Encoder"->new
l!l&&r!l&&!r
700
MC/DC0%0/2
$encoder ||= "Email::MIME::RFC2047::Encoder"->new
$encoder "Email::MIME::RFC2047::Encoder"->new
Truth table33%1/3
A ||= B
A= $encoderB= "Email::MIME::RFC2047::Encoder"->new
ABresult
1X1
011
000
65  
66 7 return join(', ', map { $_->format($encoder) } @$self);
67 }
68  
69 4 1;
70  
71 __END__
« RFC2047/Group.pm ↑ Summary RFC2047/Parser.pm »