WebSocket/URL.pm

filter: Statementstmt 100% 40 / 40 Branchbran 87.5% 21 / 24 Conditioncond 69.2% 9 / 13 MC/DCmcdc 37.5% 3 / 8 Subroutinesub 100% 9 / 9 Podpod 100% 7 / 7 totaltotal 88.1% 89 / 101 CC 18 SCAR 16.0
CC
18
Cov
91%
parse
9.5
to_string
4.0
new
3.0
CRAP 4.9
« WebSocket/Handshake/Server.pm ↑ Summary WebSocket/Cookie/Request.pm »
1 package Protocol::WebSocket::URL;
2  
3 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 212 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
7 212 my $class = shift;
8 212 ▶ $class = ref $class if ref $class;
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 212 212
9  
10 212 my $self = {@_};
11 212 bless $self, $class;
12  
13 212 ▶ $self->{secure} ||= 0;
Condition100%2/2
$self->{"secure"} ||= 0
l!l
53159
MC/DC100%1/1
$self->{"secure"} ||= 0
$self->{"secure"}
Truth table100%2/2
A
A= $self->{"secure"}
Aresult
11
00
14  
15 212 return $self;
16 }
17  
18 255 ▶sub secure { @_ > 1 ? $_[0]->{secure} = $_[1] : $_[0]->{secure} }
Subroutine secure: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 6 249 255
19  
20 285 ▶sub host { @_ > 1 ? $_[0]->{host} = $_[1] : $_[0]->{host} }
Subroutine host: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 31 254 285
21 260 ▶sub port { @_ > 1 ? $_[0]->{port} = $_[1] : $_[0]->{port} }
Subroutine port: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 31 229 260
22  
23 243 ▶sub resource_name {
Subroutine resource_name: called CC=2 SCAR=6.9
Pod documented
24 243 ▶ @_ > 1 ? $_[0]->{resource_name} = $_[1] : $_[0]->{resource_name};
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 31 212 243
25 }
26  
27 31 ▶sub parse {
Subroutine parse: called CC=9 SCAR=22.5
Pod documented
28 31 my $self = shift;
29 31 my $string = shift;
30  
31 31 my ($scheme) = $string =~ m{^(wss?)://};
32 31 ▶ return unless $scheme;
Branch: 1 branch
BranchTrueFalseTotal
unless $scheme 0 31 31
33  
34 31 ▶ $self->secure(1) if $scheme =~ m/ss$/;
Branch: 1 branch
BranchTrueFalseTotal
if $scheme =~ /ss$/ 6 25 31
35  
36 31 my ($host, $port) = $string =~ m{^$scheme://([^:\/]+)(?::(\d+))?(?:|\/|$)};
37 31 ▶ $host = '/' unless defined $host && $host ne '';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $host and $host ne "" 0 31 31
Condition33%1/3
defined $host and $host ne ""
!ll&&!rl&&r
0031
MC/DC0%0/2
defined $host and $host ne ""
defined $host $host ne ""
Truth table33%1/3
A and B
A= defined $hostB= $host ne ""
ABresult
0X0
100
111
38 31 $self->host($host);
39 31 ▶ $port ||= $self->secure ? 443 : 80;
Branch: 1 branch
BranchTrueFalseTotal
$self->secure ? : 5 15 20
Condition66%2/3
$port ||= $self->secure ? 443 : 80
l!l&&r!l&&!r
11200
MC/DC0%0/2
$port ||= $self->secure ? 443 : 80
$port $self->secure ? 443 : 80
Truth table66%2/3
A ||= B
A= $portB= $self->secure ? 443 : 80
ABresult
1X1
011
000
40 31 $self->port($port);
41  
42 # path and query
43 31 my ($pnq) = $string =~ m{^$scheme://(?:.*?)(/.*)$};
44 31 ▶ $pnq = '/' unless defined $pnq && $pnq ne '';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pnq and $pnq ne "" 17 14 31
Condition66%2/3
defined $pnq and $pnq ne ""
!ll&&!rl&&r
17014
MC/DC50%1/2
defined $pnq and $pnq ne ""
defined $pnq $pnq ne ""
Truth table66%2/3
A and B
A= defined $pnqB= $pnq ne ""
ABresult
0X0
100
111
45 31 $self->resource_name($pnq);
46  
47 31 return $self;
48 }
49  
50 181 ▶sub to_string {
Subroutine to_string: called CC=4 SCAR=13.9
Pod documented
51 181 my $self = shift;
52  
53 181 my $string = '';
54  
55 181 $string .= 'ws';
56 181 ▶ $string .= 's' if $self->secure;
Branch: 1 branch
BranchTrueFalseTotal
if $self->secure 53 128 181
57 181 $string .= '://';
58 181 $string .= $self->host;
59 181 ▶ $string .= ':' . $self->port if defined $self->port;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->port 1 180 181
60 181 ▶ $string .= $self->resource_name || '/';
Condition100%2/2
$self->resource_name || '/'
l!l
13744
MC/DC100%1/1
$self->resource_name || '/'
$self->resource_name
Truth table100%2/2
A
A= $self->resource_name
Aresult
11
00
61  
62 181 return $string;
63 }
64  
65 15 1;
66 __END__
« WebSocket/Handshake/Server.pm ↑ Summary WebSocket/Cookie/Request.pm »