Message/Field/AddrGroup.pm

filter: Statementstmt 94.1% 32 / 34 Branchbran 62.5% 10 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 4 / 4 totaltotal 87.3% 55 / 63 CC 9 SCAR 12.2
CC
9
Cov
84%
coerce
6.6
addAddress
3.1
string
3.0
CRAP 3.4
« Message/Head.pm ↑ Summary Message/Convert/EmailSimple.pm »
1 # Copyrights 2001-2022 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::AddrGroup;
10 23 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 23 $VERSION = '3.012';
12  
13 23 ▶use base 'User::Identity::Collection::Emails';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 23 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 23 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 23 ▶use overload '""' => 'string';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 #------------------------------------------
22  
23  
24 sub string()
25 52 ▶{ my $self = shift;
Subroutine string: called CC=3 SCAR=11.0
Pod documented
26 52 my $name = $self->name;
27 52 my @addr = sort map $_->string, $self->addresses;
28  
29 52 local $" = ', ';
30  
31 52 ▶ length $name ? "$name: @addr;"
Branch: 2 branches
BranchTrueFalseTotal
length $name ? : 23 29 52
@addr ? : 20 9 29
32 : @addr ? "@addr"
33 : '';
34 }
35  
36 #------------------------------------------
37  
38  
39 sub coerce($@)
40 1 ▶{ my ($class, $addr, %args) = @_;
Subroutine coerce: called CC=5 SCAR=18.9
Pod documented
41  
42 1 ▶ return () unless defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 1 1
43  
44 1 ▶ if(ref $addr)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $addr) 1 0 1
45 1 ▶ { return $addr if $addr->isa($class);
Branch: 1 branch
BranchTrueFalseTotal
if $addr->isa($class) 0 1 1
46  
47 1 ▶ return bless $addr, $class
Branch: 1 branch
BranchTrueFalseTotal
if $addr->isa("User::Identity::Collection::Emails") 1 0 1
48 if $addr->isa('User::Identity::Collection::Emails');
49 }
50  
51 0 $class->log(ERROR => "Cannot coerce a ".(ref($addr)|'string').
52 " into a $class");
53 0 ();
54 }
55  
56  
57 #------------------------------------------
58  
59  
60 sub addAddress(@)
61 25 ▶{ my $self = shift;
Subroutine addAddress: called CC=3 SCAR=11.4
Pod documented
62  
63 25 ▶ my $addr
Branch: 2 branches
BranchTrueFalseTotal
@_ > 1 ? : 0 25 25
!$_[0] ? : 0 25 25
64 = @_ > 1 ? Mail::Message::Field::Address->new(@_)
65 : !$_[0] ? return ()
66 : Mail::Message::Field::Address->coerce(shift);
67  
68 25 $self->addRole($addr);
69 25 $addr;
70 }
71  
72  
73 # roles are stored in a hash, so produce
74 72 ▶sub addresses() { shift->roles }
Subroutine addresses: called CC=1 SCAR=0.0
Pod documented
75  
76 #------------------------------------------
77  
78  
79 23 1;
« Message/Head.pm ↑ Summary Message/Convert/EmailSimple.pm »