URI.pm

filter: Statementstmt 97.5% 39 / 40 Branchbran 75.0% 12 / 16 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 8 totaltotal 81.2% 65 / 80 CC 10 SCAR 17.3
CC
10
Cov
90%
parse
10.3
BEGIN
1.0
BEGIN
1.0
CRAP 5.7
« Client.pm ↑ Summary ConnectInfo.pm »
1 package Net::NATS2::URI;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
7 6 my $class = shift;
8 6 return $class->parse(@_);
9 }
10  
11 8 ▶sub parse {
Subroutine parse: called CC=10 SCAR=23.4
Pod undocumented
12 8 my ($class, $value) = @_;
13 8 ▶ return unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 8 8
14  
15 8 my ($scheme, $authority) = $value =~ /\A(nats):\/\/([^\/?#]*)\z/i;
16 8 ▶ return unless defined $scheme && length $authority;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $scheme and length $authority 1 7 8
Condition66%2/3
defined $scheme and length $authority
!ll&&!rl&&r
107
MC/DC50%1/2
defined $scheme and length $authority
defined $scheme length $authority
Truth table66%2/3
A and B
A= defined $schemeB= length $authority
ABresult
0X0
100
111
17  
18 7 my ($userinfo, $host_port);
19 7 $host_port = $authority;
20 7 my $at = rindex($host_port, '@');
21 7 ▶ if ($at >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($at >= 0) 2 5 7
22 2 $userinfo = substr($host_port, 0, $at);
23 2 $host_port = substr($host_port, $at + 1);
24 }
25  
26 7 my ($host, $port);
27 7 ▶ if ($host_port =~ /\A\[([^\]]+)\](?::(\d+))?\z/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($host_port =~ /\A\[([^\]]+)\](?::(\d+))?\z/) { } 1 6 7
elsif ($host_port =~ /\A([^:]+)(?::(\d+))?\z/) { } 6 0 6
28 1 ($host, $port) = ($1, $2);
29 }
30 elsif ($host_port =~ /\A([^:]+)(?::(\d+))?\z/) {
31 6 ($host, $port) = ($1, $2);
32 }
33 else {
34 0 return;
35 }
36  
37 7 my ($user, $password);
38 7 ▶ if (defined $userinfo) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $userinfo) 2 5 7
39 2 ($user, $password) = split /:/, $userinfo, 2;
40 2 ▶ $user = _percent_decode($user) if defined $user;
Branch: 1 branch
BranchTrueFalseTotal
if defined $user 2 0 2
41 2 ▶ $password = _percent_decode($password) if defined $password;
Branch: 1 branch
BranchTrueFalseTotal
if defined $password 2 0 2
42 }
43  
44 7 return bless {
45 as_string => $value,
46 host => $host,
47 password => $password,
48 port => $port,
49 scheme => lc $scheme,
50 user => $user,
51 }, $class;
52 }
53  
54 4 ▶sub _percent_decode {
Subroutine _percent_decode: called CC=1 SCAR=0.0
55 4 my ($value) = @_;
56 4 $value =~ s/%([0-9A-Fa-f]{2})/chr hex $1/ge;
57 4 return $value;
58 }
59  
60 1 ▶sub as_string { return $_[0]->{as_string}; }
Subroutine as_string: called CC=1 SCAR=0.0
Pod undocumented
61 6 ▶sub host { return $_[0]->{host}; }
Subroutine host: called CC=1 SCAR=0.0
Pod undocumented
62 2 ▶sub password { return $_[0]->{password}; }
Subroutine password: called CC=1 SCAR=0.0
Pod undocumented
63 6 ▶sub port { return $_[0]->{port}; }
Subroutine port: called CC=1 SCAR=0.0
Pod undocumented
64 1 ▶sub scheme { return $_[0]->{scheme}; }
Subroutine scheme: called CC=1 SCAR=0.0
Pod undocumented
65 2 ▶sub user { return $_[0]->{user}; }
Subroutine user: called CC=1 SCAR=0.0
Pod undocumented
66  
67 5 1;
« Client.pm ↑ Summary ConnectInfo.pm »