Contacts/Item.pm

filter: Statementstmt 32.7% 19 / 58 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 40.0% 4 / 10 Podpod 100% 1 / 1 totaltotal 21.8% 24 / 110 SCAR 51.8
CC
18
Cov
21%
_build_Biz_Hashes
90.0
_build_Contact_Hashes
56.0
BUILDARGS
20.0
CRAP 178.5
« Folder/Role/Reader.pm ↑ Summary Calendar/Role/RetrieveWithinWindow.pm »
1 package EWS::Contacts::Item;
2 BEGIN {
3 1 ▶ $EWS::Contacts::Item::VERSION = '1.143070';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 }
5 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 has DisplayName => (
10 is => 'ro',
11 isa => 'Str',
12 required => 1,
13 );
14  
15 1 has JobTitle => (
16 is => 'ro',
17 isa => 'Str',
18 );
19  
20 1 has CompanyName => (
21 is => 'ro',
22 isa => 'Str',
23 );
24  
25 1 has BusinessHomePage => (
26 is => 'ro',
27 isa => 'Str',
28 );
29  
30 has PhoneNumbers => (
31 is => 'ro',
32 isa => 'HashRef[ArrayRef]',
33 0 ▶ default => sub { {} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
34 1 );
35  
36 has EmailAddresses => (
37 is => 'ro',
38 isa => 'HashRef[ArrayRef]',
39 0 ▶ default => sub { {} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
40 1 );
41  
42 has PhysicalAddresses => (
43 is => 'ro',
44 isa => 'HashRef[ArrayRef]',
45 0 ▶ default => sub { {} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
46 1 );
47  
48 sub BUILDARGS {
49 0 ▶ my ($class, @rest) = @_;
Subroutine BUILDARGS: not called CC=4 SCAR=30.0
Pod documented
50 0 ▶ my $params = (scalar @rest == 1 ? $rest[0] : {@rest});
Branch: 1 branch
BranchTrueFalseTotal
scalar @rest == 1 ? : 0 0 0
51  
52 0 $params->{'PhoneNumbers'} = _build_Contact_Hashes($params->{'PhoneNumbers'});
53 0 $params->{'EmailAddresses'} = _build_Contact_Hashes($params->{'EmailAddresses'});
54 0 $params->{'PhysicalAddresses'} = _build_Biz_Hashes($params->{'PhysicalAddresses'});
55  
56 0 foreach my $key (keys %$params) {
57 0 ▶ if (not ref $params->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $params->{$key}) 0 0 0
58 0 $params->{$key} = Encode::encode('utf8', $params->{$key});
59 }
60 }
61  
62 0 return $params;
63 }
64  
65 sub _build_Contact_Hashes {
66 0 ▶ my $values = shift;
Subroutine _build_Contact_Hashes: not called CC=7 SCAR=40.3
67 0 my $entries = {};
68  
69 return {} if !exists $values->{'Entry'}
70 or ref $values->{'Entry'} ne 'ARRAY'
71 0 ▶ or scalar @{ $values->{'Entry'} } == 0;
Branch: 1 branch
BranchTrueFalseTotal
if not exists $values->{"Entry"} or ref $values->{"Entry"} ne "ARRAY" or scalar @{$values->{"Entry"};} == 0 0 0 0
Condition0%0/6
not exists $values->{"Entry"} or ref $values->{"Entry"} ne "ARRAY" or scalar @{$values->{"Entry"};} == 0
l!l&&r!l&&!r
000
not exists $values->{"Entry"} or ref $values->{"Entry"} ne "ARRAY"
l!l&&r!l&&!r
000
MC/DC0%0/3
not exists $values->{"Entry"} or ref $values->{"Entry"} ne "ARRAY" or scalar @{$values->{"Entry"};} == 0
not exists $values->{"Entry"} ref $values->{"Entry"} ne "ARRAY" scalar @{$values->{"Entry"};} == 0
Truth table0%0/4
not(A) or B or C
A= not exists $values->{"Entry"}B= ref $values->{"Entry"} ne "ARRAY"C= scalar @{$values->{"Entry"};} == 0
ABCresult
1XX1
01X1
0011
0000
72  
73 0 foreach my $entry (@{ $values->{'Entry'} }) {
74 0 ▶ next if !defined $entry->{'Key'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $entry->{"Key"} 0 0 0
75 #or $entry->{'Key'} =~ m/(?:Fax|Callback|Isdn|Pager|Telex|TtyTdd)/i;
76  
77 0 my $type = $entry->{'Key'};
78 0 $type =~ s/(\w)([A-Z0-9])/$1 $2/g; # BusinessPhone -> Business Phone
79  
80 # get numbers and set mapping to this name, but skip blanks
81 0 ▶ next unless $entry->{'_'};
Branch: 1 branch
BranchTrueFalseTotal
unless $entry->{"_"} 0 0 0
82 0 push @{ $entries->{$type} }, $entry->{'_'};
83 }
84  
85 0 return $entries;
86 }
87  
88 sub _build_Biz_Hashes {
89 0 ▶ my $values = shift;
Subroutine _build_Biz_Hashes: not called CC=9 SCAR=45.0
90 0 my $entries = {};
91  
92 return {} if !exists $values->{'Entry'}
93 or ref $values->{'Entry'} ne 'ARRAY'
94 0 ▶ or scalar @{ $values->{'Entry'} } == 0;
Branch: 1 branch
BranchTrueFalseTotal
if not exists $values->{"Entry"} or ref $values->{"Entry"} ne "ARRAY" or scalar @{$values->{"Entry"};} == 0 0 0 0
Condition0%0/6
not exists $values->{"Entry"} or ref $values->{"Entry"} ne "ARRAY" or scalar @{$values->{"Entry"};} == 0
l!l&&r!l&&!r
000
not exists $values->{"Entry"} or ref $values->{"Entry"} ne "ARRAY"
l!l&&r!l&&!r
000
MC/DC0%0/3
not exists $values->{"Entry"} or ref $values->{"Entry"} ne "ARRAY" or scalar @{$values->{"Entry"};} == 0
not exists $values->{"Entry"} ref $values->{"Entry"} ne "ARRAY" scalar @{$values->{"Entry"};} == 0
Truth table0%0/4
not(A) or B or C
A= not exists $values->{"Entry"}B= ref $values->{"Entry"} ne "ARRAY"C= scalar @{$values->{"Entry"};} == 0
ABCresult
1XX1
01X1
0011
0000
95  
96 0 foreach my $entry (@{ $values->{'Entry'} }) {
97 0 ▶ next if !defined $entry->{'Key'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $entry->{"Key"} 0 0 0
98 0 my $type = $entry->{'Key'};
99  
100 0 ▶ while( my ($fieldname, $fieldvalue) = each %$entry ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$entry) 0 0 0
101 0 $fieldname =~ s/(\w)([A-Z0-9])/$1 $2/g;
102 0 ▶ next unless $fieldvalue and $fieldname ne 'Key';
Branch: 1 branch
BranchTrueFalseTotal
unless $fieldvalue and $fieldname ne "Key" 0 0 0
Condition0%0/3
$fieldvalue and $fieldname ne "Key"
!ll&&!rl&&r
000
MC/DC0%0/2
$fieldvalue and $fieldname ne "Key"
$fieldvalue $fieldname ne "Key"
Truth table0%0/3
A and B
A= $fieldvalueB= $fieldname ne "Key"
ABresult
0X0
100
111
103 0 push @{ $entries->{"$type $fieldname"} }, $fieldvalue;
104 }
105 }
106  
107 0 return $entries;
108 }
109  
110 1 __PACKAGE__->meta->make_immutable;
111 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
112 1 1;
« Folder/Role/Reader.pm ↑ Summary Calendar/Role/RetrieveWithinWindow.pm »