RFC2047/Group.pm

filter: Statementstmt 100% 40 / 40 Branchbran 60.0% 6 / 10 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 9 / 9 Podpod 100% 4 / 4 totaltotal 83.5% 61 / 73 SCAR 21.0
CC
8
Cov
86%
format
5.8
name
2.0
mailbox_list
2.0
CRAP 8.2
« RFC2047/Address.pm ↑ Summary RFC2047/AddressList.pm »
1 package Email::MIME::RFC2047::Group;
2 4 $Email::MIME::RFC2047::Group::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 mailbox groups
7  
8 4 ▶use base qw(Email::MIME::RFC2047::Address);
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::MailboxList;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub new {
14 9 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=6.9
Pod documented
15  
16 9 my $self;
17  
18 9 ▶ if (@_ >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ >= 2) { } 7 2 9
19 7 $self = { @_ };
20 }
21 else {
22 2 $self = $_[0];
23 }
24  
25 9 return bless($self, $class);
26 }
27  
28 #sub _parse {
29 # my ($class, $string, $decoder) = @_;
30 # my $string_ref = ref($string) ? $string : \$string;
31 #
32 # $decoder ||= Email::MIME::RFC2047::Decoder->new();
33 #
34 # my $name = $decoder->decode_phrase($string_ref);
35 # return $class->_parse_error($string_ref, 'group name')
36 # if $name eq '';
37 #
38 # $$string_ref =~ /\G:/cg
39 # or return $class->_parse_error($string_ref, 'group');
40 #
41 # my $mailbox_list;
42 #
43 # if ($$string_ref =~ /\G\s*;\s*/cg) {
44 # $mailbox_list = Email::MIME::RFC2047::MailboxList->new();
45 # }
46 # else {
47 # $mailbox_list = Email::MIME::RFC2047::MailboxList->parse(
48 # $string_ref, $decoder
49 # );
50 #
51 # $$string_ref =~ /\G;\s*/cg
52 # or return $class->_parse_error($string_ref, 'group');
53 # }
54 #
55 # my $group = $class->new(
56 # name => $name,
57 # mailbox_list => $mailbox_list,
58 # );
59 #
60 # if (!ref($string) && pos($string) < length($string)) {
61 # return $class->_parse_error($string_ref);
62 # }
63 #
64 # return $group;
65 #}
66  
67 sub name {
68 2 ▶ my $self = shift;
Subroutine name: called CC=2 SCAR=7.0
Pod documented
69  
70 2 my $old_name = $self->{name};
71 2 ▶ $self->{name} = $_[0] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 2 2
72  
73 2 return $old_name;
74 }
75  
76 sub mailbox_list {
77 2 ▶ my $self = shift;
Subroutine mailbox_list: called CC=2 SCAR=7.0
Pod documented
78  
79 2 my $old_mailbox_list = $self->{mailbox_list};
80 2 ▶ $self->{mailbox_list} = $_[0] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 2 2
81  
82 2 return $old_mailbox_list;
83 }
84  
85 sub format {
86 3 ▶ my ($self, $encoder) = @_;
Subroutine format: called CC=5 SCAR=17.6
Pod documented
87 3 ▶ $encoder ||= Email::MIME::RFC2047::Encoder->new();
Condition33%1/3
$encoder ||= "Email::MIME::RFC2047::Encoder"->new
l!l&&r!l&&!r
300
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
88  
89 3 my $name = $self->{name};
90 3 ▶ die("empty group name") if !defined($name) || $name eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $name or $name eq "" 0 3 3
Condition33%1/3
not defined $name or $name eq ""
l!l&&r!l&&!r
003
MC/DC0%0/2
not defined $name or $name eq ""
not defined $name $name eq ""
Truth table33%1/3
not(A) or B
A= not defined $nameB= $name eq ""
ABresult
1X1
011
000
91  
92 3 my $result = $encoder->encode_phrase($name) . ': ';
93  
94 3 my $mailbox_list = $self->{mailbox_list};
95 3 ▶ $result .= $mailbox_list->format($encoder) if $mailbox_list;
Branch: 1 branch
BranchTrueFalseTotal
if $mailbox_list 3 0 3
96  
97 3 $result .= ';';
98  
99 3 return $result;
100 }
101  
102 4 1;
103  
104 __END__
« RFC2047/Address.pm ↑ Summary RFC2047/AddressList.pm »