RFC2047/Address.pm

filter: Statementstmt 97.8% 46 / 47 Branchbran 83.3% 15 / 18 Conditioncond 66.6% 4 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 88.1% 74 / 84 SCAR 24.9
CC
12
Cov
92%
parse
12.3
BEGIN
1.0
BEGIN
1.0
CRAP 12.1
« RFC2047/Decoder.pm ↑ Summary RFC2047/Group.pm »
1 package Email::MIME::RFC2047::Address;
2 4 $Email::MIME::RFC2047::Address::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 addresses
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::Group;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Email::MIME::RFC2047::Mailbox;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use Email::MIME::RFC2047::MailboxList;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 4 my $domain_part_re = qr/[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?/;
16 4 my $addr_spec_re = qr{
17 [\w&'*+.\/=?^{}~-]+
18 \@
19 $domain_part_re (?: \. $domain_part_re)+
20 }x;
21  
22 sub parse {
23 36 ▶ my ($class, $string, $decoder) = @_;
Subroutine parse: called CC=12 SCAR=25.1
Pod documented
24 36 ▶ my $string_ref = ref($string) ? $string : \$string;
Branch: 1 branch
BranchTrueFalseTotal
ref $string ? : 19 17 36
25  
26 36 my $address;
27  
28 36 ▶ if ($$string_ref =~ /\G\s*($addr_spec_re)\s*/cg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$string_ref =~ /\G\s*($addr_spec_re)\s*/cg) { } 9 27 36
29 9 $address = Email::MIME::RFC2047::Mailbox->new($1);
30 }
31 else {
32 27 ▶ $decoder ||= Email::MIME::RFC2047::Decoder->new();
Condition66%2/3
$decoder ||= "Email::MIME::RFC2047::Decoder"->new
l!l&&r!l&&!r
12150
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
33 27 my $name = $decoder->decode_phrase($string_ref);
34  
35 27 ▶ if ($$string_ref =~ /\G<\s*($addr_spec_re)\s*>\s*/cg) {
Branch: 2 branches
BranchTrueFalseTotal
if ($$string_ref =~ /\G<\s*($addr_spec_re)\s*>\s*/cg) { } 17 10 27
elsif ($$string_ref =~ /\G:/cg) { } 8 2 10
36 17 my $addr_spec = $1;
37  
38 17 $address = Email::MIME::RFC2047::Mailbox->new(
39 address => $addr_spec,
40 );
41  
42 17 ▶ $address->name($name) if $name ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $name ne "" 15 2 17
43 }
44 elsif ($$string_ref =~ /\G:/cg) {
45 8 ▶ return $class->_parse_error($string_ref, 'group name')
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "" 0 8 8
46 if $name eq '';
47  
48 8 my $mailbox_list;
49  
50 8 ▶ if ($$string_ref =~ /\G\s*;\s*/cg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$string_ref =~ /\G\s*;\s*/cg) { } 2 6 8
51 2 $mailbox_list = Email::MIME::RFC2047::MailboxList->new();
52 }
53 else {
54 6 $mailbox_list = Email::MIME::RFC2047::MailboxList->parse(
55 $string_ref, $decoder
56 );
57  
58 4 ▶ $$string_ref =~ /\G;\s*/cg
Branch: 1 branch
BranchTrueFalseTotal
$$string_ref =~ /\G;\s*/cg or return $class->_parse_error($string_ref, "group") 0 4 4
59 or return $class->_parse_error($string_ref, 'group');
60 }
61  
62 6 $address = Email::MIME::RFC2047::Group->new(
63 name => $name,
64 mailbox_list => $mailbox_list,
65 );
66 }
67 else {
68 2 return $class->_parse_error($string_ref, 'address');
69 }
70 }
71  
72 32 ▶ if (!ref($string) && pos($string) < length($string)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $string and pos $string < length $string) 0 32 32
Condition66%2/3
not ref $string and pos $string < length $string
!ll&&!rl&&r
17150
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
73 0 return $class->_parse_error($string_ref);
74 }
75  
76 32 return $address;
77 }
78  
79 4 1;
80  
81 __END__
« RFC2047/Decoder.pm ↑ Summary RFC2047/Group.pm »