Folder/Item.pm

filter: Statementstmt 42.1% 35 / 83 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.1% 8 / 19 Podpod 20.0% 1 / 5 totaltotal 36.3% 44 / 121 SCAR 37.5
CC
11
Cov
36%
printAndSumSizes
20.0
_build_MessageSize
12.0
toString
12.0
CRAP 42.6
« Contacts/Role/Reader.pm ↑ Summary DistributionList/Role/Reader.pm »
1 package EWS::Folder::Item;
2 BEGIN {
3 1 ▶ $EWS::Folder::Item::VERSION = '1.143070';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 }
5  
6 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use DateTime::Format::ISO8601;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use HTML::Strip;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 has ChildFolderCount => (
14 is => 'ro',
15 isa => 'Int',
16 );
17  
18 1 has DisplayName => (
19 is => 'ro',
20 isa => 'Str',
21 required => 1,
22 );
23  
24 1 has ExtendedProperty => (
25 is => 'ro',
26 isa => 'ArrayRef',
27 );
28  
29 1 has FolderClass => (
30 is => 'ro',
31 isa => 'Str',
32 required => 0,
33 );
34  
35 1 has FolderId => (
36 is => 'ro',
37 isa => 'Any',
38 lazy_build => 1,
39 );
40  
41 sub _build_FolderId {
42 0 ▶ my $self = shift;
Subroutine _build_FolderId: not called CC=1 SCAR=6.9
43 0 return $self->{Id};
44 }
45  
46 1 has FudgeSize => (
47 is => 'ro',
48 isa => 'Int',
49 lazy_build => 1,
50 );
51  
52 sub _build_FudgeSize {
53 0 ▶ my $self = shift;
Subroutine _build_FudgeSize: not called CC=2 SCAR=17.9
54 # This appears to be the difference between the sizes returned from Exchange
55 # and those in Outlook
56 0 my $size = $self->MessageSize;
57 0 ▶ if ( defined( $self->TotalCount ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->TotalCount) 0 0 0
58 0 $size += $self->TotalCount * 8000;
59 }
60 0 return $size;
61 }
62  
63 1 has MessageSize => (
64 is => 'ro',
65 isa => 'Int',
66 lazy_build => 1,
67 );
68  
69 sub _build_MessageSize {
70 0 ▶ my $self = shift;
Subroutine _build_MessageSize: not called CC=3 SCAR=24.8
71 0 my $size = 0;
72 0 foreach my $prop (@{$self->{ExtendedProperty}}) {
73 0 ▶ if ($prop->{ExtendedFieldURI}->{PropertyTag} eq '0xe08') {
Branch: 1 branch
BranchTrueFalseTotal
if ($prop->{"ExtendedFieldURI"}{"PropertyTag"} eq "0xe08") 0 0 0
74 0 $size = $prop->{Value};
75 }
76 }
77 0 return $size;
78 }
79  
80 1 has ParentFolderId => (
81 is => 'ro',
82 isa => 'Any',
83 lazy_build => 1,
84 );
85  
86 sub _build_ParentFolderId {
87 0 ▶ my $self = shift;
Subroutine _build_ParentFolderId: not called CC=1 SCAR=6.9
88 0 return $self->{Id};
89 }
90  
91 1 has TotalCount => (
92 is => 'ro',
93 isa => 'Int',
94 );
95  
96 1 has SubFolders => (
97 is => 'ro',
98 isa => 'ArrayRef[EWS::Folder::Item]',
99 lazy_build => 1,
100 );
101  
102 sub _build_SubFolders {
103 0 ▶ my $self = shift;
Subroutine _build_SubFolders: not called CC=2 SCAR=17.9
104 0 ▶ return exists $self->{items} ? $self->{items} : [];
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'items'} ? : 0 0 0
105 }
106  
107 sub BUILDARGS {
108 0 ▶ my ($class, @rest) = @_;
Subroutine BUILDARGS: not called CC=2 SCAR=17.9
Pod documented
109 0 ▶ my $params = (scalar @rest == 1 ? $rest[0] : {@rest});
Branch: 1 branch
BranchTrueFalseTotal
scalar @rest == 1 ? : 0 0 0
110  
111 0 return $params;
112 }
113  
114 sub SubFolder_count {
115 0 ▶ my $self = shift;
Subroutine SubFolder_count: not called CC=1 SCAR=6.9
Pod undocumented
116 0 return scalar @{$self->SubFolders};
117 }
118  
119 1 has iterator => (
120 is => 'ro',
121 isa => 'MooseX::Iterator::Array',
122 handles => [qw/
123 next
124 has_next
125 peek
126 reset
127 /],
128 lazy_build => 1,
129 );
130  
131 1 __PACKAGE__->meta->make_immutable;
132 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
133  
134 sub _build_iterator {
135 0 ▶ my $self = shift;
Subroutine _build_iterator: not called CC=1 SCAR=6.9
136 0 return MooseX::Iterator::Array->new( collection => $self->SubFolders );
137 }
138  
139 sub printAndSumSizes {
140 0 ▶ my ($self, $pad) = @_;
Subroutine printAndSumSizes: not called CC=4 SCAR=30.0
Pod undocumented
141 # my $size = $self->MessageSize;
142 0 my $size = $self->FudgeSize;
143 0 my $dispSize = $size;
144  
145 0 ▶ if ( $dispSize > 1024 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dispSize > 1024) 0 0 0
146 0 $dispSize = commify($dispSize / 1024). " KB";
147 }
148 0 ▶ if ( $self->ChildFolderCount > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->ChildFolderCount > 0) { } 0 0 0
149 0 print $pad. $self->DisplayName. ":\n";
150 0 foreach my $item (@{$self->SubFolders}) {
151 0 $size += $item->printAndSumSizes($pad." ");
152 }
153 0 print $pad. $self->DisplayName. " Size=". $dispSize. " Total=$size\n";
154 }
155 else {
156 0 print $pad. $self->DisplayName. " Size=". $dispSize. "\n";
157 }
158 0 return $size;
159 }
160  
161 sub commify {
162 0 ▶ my $text = reverse sprintf "%.0f", $_[0];
Subroutine commify: not called CC=1 SCAR=6.9
Pod undocumented
163 0 $text =~ s/(\d\d\d)(?=\d)(?!d*\.)/$1,/g;
164 0 return scalar reverse $text;
165 }
166  
167 sub toString {
168 0 ▶ my ($self, $pad) = @_;
Subroutine toString: not called CC=3 SCAR=24.8
Pod undocumented
169  
170 0 print $pad. $self->DisplayName. ": Size=". $self->MessageSize. "\n";
171 0 ▶ if ( $self->ChildFolderCount > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->ChildFolderCount > 0) 0 0 0
172 0 foreach my $item (@{$self->SubFolders}) {
173 0 $item->toString($pad." ");
174 }
175 }
176 }
177  
178 1 1;
« Contacts/Role/Reader.pm ↑ Summary DistributionList/Role/Reader.pm »