| 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
| |||||||||||||||||||||||||||||
| 17 | 171 | ▶ | if ( defined $params->{blocked} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | 165 | $self->blocked( $params->{blocked} ); | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | 171 | ▶ | if ( defined $params->{dns} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 165 | $self->dns( $params->{dns} ); | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | 171 | ▶ | if ( defined $params->{connect} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 30 | 96 | $self->ssl( $params->{ssl} ); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | 171 | ▶ | if ( defined $params->{comment} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 48 | 166 | ▶ | if ( defined $new ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
defined $old and $old eq _DOES_NOT_APPLY()
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()
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 67 | 166 | ▶ | if ( defined $new ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
defined $old and $old eq _DOES_NOT_APPLY()
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()
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 86 | 166 | ▶ | if ( defined $new ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
defined $old and $old eq _DOES_NOT_APPLY()
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()
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 132 | 99 | ▶ | if ( defined $new ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
defined $old and $old eq _DOES_NOT_APPLY()
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()
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 164 | 4 | $old = $self->{$name}; | |||||||||||||||||||||||||||
| 165 | 4 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
MC/DC100%1/1
$self->send || 0
$self->send
Truth table100%2/2
A
A= $self->send
| |||||||||||||||||||||||||||||
| 201 | 489 | ▶ | $json->{wait} = ( $self->wait() || 0 ) + 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->wait || 0
MC/DC100%1/1
$self->wait || 0
$self->wait
Truth table100%2/2
A
A= $self->wait
| |||||||||||||||||||||||||||||
| 202 | 489 | ▶ | $json->{receive} = ( $self->receive() || 0 ) + 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->receive || 0
MC/DC100%1/1
$self->receive || 0
$self->receive
Truth table100%2/2
A
A= $self->receive
| |||||||||||||||||||||||||||||
| 203 | 489 | ▶ | if ( defined $self->ssl() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 214 | 3085 | ▶ | if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | 21 | $json->{$key} = $self->{$key}; | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 489 | return $json; | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 10 | 1; | |||||||||||||||||||||||||||
| 223 | __END__ | ||||||||||||||||||||||||||||