Har/Entry/Timings.pm

filter: Statementstmt 100% 130 / 130 Branchbran 100% 66 / 66 Conditioncond 100% 18 / 18 MC/DCmcdc 100% 11 / 11 Subroutinesub 100% 16 / 16 Podpod 90.0% 9 / 10 totaltotal 99.6% 250 / 251 CC 43 SCAR 18.3
CC
43
Cov
100%
TO_JSON
12.0
new
9.0
blocked
5.0
CRAP 6.2
« Har/Entry/Cookie.pm ↑ Summary Har/Entry/Cache.pm »
1 package Archive::Har::Entry::Timings;
2  
3 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use Carp();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 10 ▶use Archive::Har::Entry::Cache::Request();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 10 our $VERSION = '0.21';
9  
10 5320 ▶sub _DOES_NOT_APPLY { return -1 }
Subroutine _DOES_NOT_APPLY: called CC=1 SCAR=0.0
11  
12 354 ▶sub new {
Subroutine new: called CC=9 SCAR=22.0
Pod documented
13 354 my ( $class, $params ) = @_;
14 354 my $self = {};
15 354 bless $self, $class;
16 354 ▶ if ( defined $params ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params) 171 183 354
17 171 ▶ if ( defined $params->{blocked} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params->{"blocked"}) 165 6 171
18 165 $self->blocked( $params->{blocked} );
19 }
20 171 ▶ if ( defined $params->{dns} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params->{"dns"}) 165 6 171
21 165 $self->dns( $params->{dns} );
22 }
23 171 ▶ if ( defined $params->{connect} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params->{"connect"}) 165 6 171
24 165 $self->connect( $params->{connect} );
25 }
26 171 $self->send( $params->{send} );
27 171 $self->wait( $params->{wait} );
28 171 $self->receive( $params->{receive} );
29 171 ▶ if ( defined $params->{ssl} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params->{"ssl"}) 96 75 171
30 96 $self->ssl( $params->{ssl} );
31 }
32 171 ▶ if ( defined $params->{comment} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params->{"comment"}) 1 170 171
33 1 $self->comment( $params->{comment} );
34 }
35 171 foreach my $key ( sort { $a cmp $b } keys %{$params} ) {
36 1103 ▶ if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^_[[:alnum:]]+$/msx) 1 1102 1103
37 1 $self->$key( $params->{$key} );
38 }
39 }
40 }
41 354 return $self;
42 }
43  
44 1573 ▶sub blocked {
Subroutine blocked: called CC=5 SCAR=16.1
Pod documented
45 1573 my ( $self, $new ) = @_;
46 1573 my $old = $self->{blocked};
47 1573 ▶ if ( @_ > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 166 1407 1573
48 166 ▶ if ( defined $new ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new) { } 165 1 166
49 165 $self->{blocked} = $new + 0;
50 }
51 else {
52 1 $self->{blocked} = _DOES_NOT_APPLY();
53 }
54 }
55 1573 ▶ if ( ( defined $old ) && ( $old eq _DOES_NOT_APPLY() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $old and $old eq _DOES_NOT_APPLY()) { } 74 1499 1573
Condition100%3/3
defined $old and $old eq _DOES_NOT_APPLY()
!ll&&!rl&&r
220127974
MC/DC100%2/2
defined $old and $old eq _DOES_NOT_APPLY()
defined $old $old eq _DOES_NOT_APPLY()
Truth table100%3/3
A and B
A= defined $oldB= $old eq _DOES_NOT_APPLY()
ABresult
0X0
100
111
56 74 return;
57 }
58 else {
59 1499 return $old;
60 }
61 }
62  
63 1359 ▶sub dns {
Subroutine dns: called CC=5 SCAR=16.1
Pod documented
64 1359 my ( $self, $new ) = @_;
65 1359 my $old = $self->{dns};
66 1359 ▶ if ( @_ > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 166 1193 1359
67 166 ▶ if ( defined $new ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new) { } 165 1 166
68 165 $self->{dns} = $new + 0;
69 }
70 else {
71 1 $self->{dns} = _DOES_NOT_APPLY();
72 }
73 }
74 1359 ▶ if ( ( defined $old ) && ( $old eq _DOES_NOT_APPLY() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $old and $old eq _DOES_NOT_APPLY()) { } 506 853 1359
Condition100%3/3
defined $old and $old eq _DOES_NOT_APPLY()
!ll&&!rl&&r
220633506
MC/DC100%2/2
defined $old and $old eq _DOES_NOT_APPLY()
defined $old $old eq _DOES_NOT_APPLY()
Truth table100%3/3
A and B
A= defined $oldB= $old eq _DOES_NOT_APPLY()
ABresult
0X0
100
111
75 506 return;
76 }
77 else {
78 853 return $old;
79 }
80 }
81  
82 1589 ▶sub connect {
Subroutine connect: called CC=5 SCAR=16.1
Pod documented
83 1589 my ( $self, $new ) = @_;
84 1589 my $old = $self->{connect};
85 1589 ▶ if ( @_ > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 166 1423 1589
86 166 ▶ if ( defined $new ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new) { } 165 1 166
87 165 $self->{connect} = $new + 0;
88 }
89 else {
90 1 $self->{connect} = _DOES_NOT_APPLY();
91 }
92 }
93 1589 ▶ if ( ( defined $old ) && ( $old eq _DOES_NOT_APPLY() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $old and $old eq _DOES_NOT_APPLY()) { } 42 1547 1589
Condition100%3/3
defined $old and $old eq _DOES_NOT_APPLY()
!ll&&!rl&&r
220132742
MC/DC100%2/2
defined $old and $old eq _DOES_NOT_APPLY()
defined $old $old eq _DOES_NOT_APPLY()
Truth table100%3/3
A and B
A= defined $oldB= $old eq _DOES_NOT_APPLY()
ABresult
0X0
100
111
94 42 return;
95 }
96 else {
97 1547 return $old;
98 }
99 }
100  
101 1158 ▶sub send {
Subroutine send: called CC=2 SCAR=6.9
Pod documented
102 1158 my ( $self, $new ) = @_;
103 1158 my $old = $self->{send};
104 1158 ▶ if ( @_ > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 176 982 1158
105 176 $self->{send} = $new;
106 }
107 1158 return $old;
108 }
109  
110 1158 ▶sub wait {
Subroutine wait: called CC=2 SCAR=6.9
Pod documented
111 1158 my ( $self, $new ) = @_;
112 1158 my $old = $self->{wait};
113 1158 ▶ if ( @_ > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 176 982 1158
114 176 $self->{wait} = $new;
115 }
116 1158 return $old;
117 }
118  
119 1158 ▶sub receive {
Subroutine receive: called CC=2 SCAR=6.9
Pod documented
120 1158 my ( $self, $new ) = @_;
121 1158 my $old = $self->{receive};
122 1158 ▶ if ( @_ > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 176 982 1158
123 176 $self->{receive} = $new;
124 }
125 1158 return $old;
126 }
127  
128 1170 ▶sub ssl {
Subroutine ssl: called CC=5 SCAR=16.1
Pod documented
129 1170 my ( $self, $new ) = @_;
130 1170 my $old = $self->{ssl};
131 1170 ▶ if ( @_ > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 99 1071 1170
132 99 ▶ if ( defined $new ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new) { } 98 1 99
133 98 $self->{ssl} = $new;
134 }
135 else {
136 1 $self->{ssl} = _DOES_NOT_APPLY();
137 }
138 }
139 1170 ▶ if ( ( defined $old ) && ( $old eq _DOES_NOT_APPLY() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $old and $old eq _DOES_NOT_APPLY()) { } 392 778 1170
Condition100%3/3
defined $old and $old eq _DOES_NOT_APPLY()
!ll&&!rl&&r
505273392
MC/DC100%2/2
defined $old and $old eq _DOES_NOT_APPLY()
defined $old $old eq _DOES_NOT_APPLY()
Truth table100%3/3
A and B
A= defined $oldB= $old eq _DOES_NOT_APPLY()
ABresult
0X0
100
111
140 392 return;
141 }
142 else {
143 778 return $old;
144 }
145 }
146  
147 512 ▶sub comment {
Subroutine comment: called CC=2 SCAR=6.9
Pod documented
148 512 my ( $self, $new ) = @_;
149 512 my $old = $self->{comment};
150 512 ▶ if ( @_ > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 1 511 512
151 1 $self->{comment} = $new;
152 }
153 512 return $old;
154 }
155  
156 357 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=4 SCAR=13.9
157 357 my ( $self, $new ) = @_;
158  
159 357 my $name = $Archive::Har::Entry::Timings::AUTOLOAD;
160 357 $name =~ s/.*://smx; # strip fully-qualified portion
161  
162 357 my $old;
163 357 ▶ if ( $name =~ /^_[[:alnum:]]+$/smx ) { # private fields
Branch: 2 branches
BranchTrueFalseTotal
if ($name =~ /^_[[:alnum:]]+$/msx) { } 4 353 357
elsif ($name eq 'DESTROY') { } 352 1 353
164 4 $old = $self->{$name};
165 4 ▶ if ( @_ > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 3 1 4
166 3 $self->{$name} = $new;
167 }
168 }
169 elsif ( $name eq 'DESTROY' ) {
170 }
171 else {
172 1 Carp::croak(
173 "$name is not specified in the HAR 1.2 spec and does not start with an underscore"
174 );
175 }
176 356 return $old;
177 }
178  
179 489 ▶sub TO_JSON {
Subroutine TO_JSON: called CC=12 SCAR=24.8
Pod undocumented
180 489 my ($self) = @_;
181 489 my $json = {};
182 489 ▶ if ( defined $self->blocked() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->blocked) { } 425 64 489
183 425 $json->{blocked} = $self->blocked() + 0;
184 }
185 else {
186 64 $json->{blocked} = _DOES_NOT_APPLY();
187 }
188 489 ▶ if ( defined $self->dns() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->dns) { } 211 278 489
189 211 $json->{dns} = $self->dns() + 0;
190 }
191 else {
192 278 $json->{dns} = _DOES_NOT_APPLY();
193 }
194 489 ▶ if ( defined $self->connect() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->connect) { } 441 48 489
195 441 $json->{connect} = $self->connect() + 0;
196 }
197 else {
198 48 $json->{connect} = _DOES_NOT_APPLY();
199 }
200 489 ▶ $json->{send} = ( $self->send() || 0 ) + 0;
Condition100%2/2
$self->send || 0
l!l
21468
MC/DC100%1/1
$self->send || 0
$self->send
Truth table100%2/2
A
A= $self->send
Aresult
11
00
201 489 ▶ $json->{wait} = ( $self->wait() || 0 ) + 0;
Condition100%2/2
$self->wait || 0
l!l
45336
MC/DC100%1/1
$self->wait || 0
$self->wait
Truth table100%2/2
A
A= $self->wait
Aresult
11
00
202 489 ▶ $json->{receive} = ( $self->receive() || 0 ) + 0;
Condition100%2/2
$self->receive || 0
l!l
265224
MC/DC100%1/1
$self->receive || 0
$self->receive
Truth table100%2/2
A
A= $self->receive
Aresult
11
00
203 489 ▶ if ( defined $self->ssl() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->ssl) { } 89 400 489
204 89 $json->{ssl} = $self->ssl() + 0;
205 }
206 else {
207 400 $json->{ssl} = _DOES_NOT_APPLY();
208 }
209 489 ▶ if ( defined $self->comment() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->comment) 22 467 489
210 22 $json->{comment} = $self->comment();
211 }
212 489 foreach my $key ( sort { $a cmp $b } keys %{$self} ) {
213 3152 ▶ next if ( !defined $self->{$key} );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{$key} 67 3085 3152
214 3085 ▶ if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^_[[:alnum:]]+$/msx) 21 3064 3085
215 21 $json->{$key} = $self->{$key};
216 }
217 }
218  
219 489 return $json;
220 }
221  
222 10 1;
223 __END__
« Har/Entry/Cookie.pm ↑ Summary Har/Entry/Cache.pm »