Util/Collection/Tie.pm

filter: Statementstmt 47.9% 35 / 73 Branchbran 11.1% 2 / 18 Conditioncond 9.0% 1 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 55.5% 10 / 18 Podpod 100% 1 / 1 totaltotal 38.2% 49 / 128 CC 14 SCAR 33.9
CC
14
Cov
37%
_checktype
85.8
SPLICE
12.0
new
2.1
CRAP 29.8
↑ Summary Util.pm »
1 package Net::IPAddress::Util::Collection::Tie;
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 5 ▶use 5.012;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use Carp qw( confess );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 require Net::IPAddress::Util;
10  
11 46 ▶sub new {
Subroutine new: called CC=2 SCAR=7.4
Pod documented
12 46 my $class = shift;
13 46 ▶ $class = ref($class) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
0460
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
14 46 my ($arg_ref) = @_;
15 46 return bless $arg_ref => $class;
16 }
17  
18 46 ▶sub TIEARRAY {
Subroutine TIEARRAY: called CC=2 SCAR=7.0
19 46 my ($class, $contents) = @_;
20 46 ▶ $contents = [] unless defined $contents;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $contents 0 46 46
21 46 @{$contents} = map { _checktype($_) } @{$contents};
22 46 my $self = $class->new({ contents => $contents });
23 }
24  
25 258 ▶sub FETCH {
Subroutine FETCH: called CC=1 SCAR=0.0
26 258 my ($self, $i) = @_;
27 258 return $self->{ contents }->[ $i ];
28 }
29  
30 0 ▶sub STORE {
Subroutine STORE: not called CC=1 SCAR=6.9
31 0 my ($self, $i, $v) = @_;
32 0 $self->{ contents }->[ $i ] = _checktype($v);
33 0 return $v;
34 }
35  
36 56 ▶sub FETCHSIZE {
Subroutine FETCHSIZE: called CC=1 SCAR=0.0
37 56 my ($self) = @_;
38 56 return scalar @{$self->{ contents }};
39 }
40  
41 0 ▶sub EXISTS {
Subroutine EXISTS: not called CC=1 SCAR=6.9
42 0 my ($self, $i) = @_;
43 0 return exists $self->{ contents }->[ $i ];
44 }
45  
46 0 ▶sub DELETE {
Subroutine DELETE: not called CC=1 SCAR=6.9
47 0 my ($self, $i) = @_;
48 0 return delete $self->{ contents }->[ $i ];
49 }
50  
51 0 ▶sub CLEAR {
Subroutine CLEAR: not called CC=1 SCAR=6.9
52 0 my ($self) = @_;
53 0 $self->{ contents } = [ ];
54 0 return $self->{ contents };
55 }
56  
57 68 ▶sub PUSH {
Subroutine PUSH: called CC=1 SCAR=0.0
58 68 my ($self, @l) = @_;
59 68 push @{$self->{ contents }}, map { _checktype($_) } @l;
60 }
61  
62 0 ▶sub POP {
Subroutine POP: not called CC=1 SCAR=6.9
63 0 my ($self) = @_;
64 0 return pop @{$self->{ contents }};
65 }
66  
67 0 ▶sub UNSHIFT {
Subroutine UNSHIFT: not called CC=1 SCAR=6.9
68 0 my ($self, @l) = @_;
69 0 unshift @{$self->{ contents }}, map { _checktype($_) } @l;
70 }
71  
72 0 ▶sub SHIFT {
Subroutine SHIFT: not called CC=1 SCAR=6.9
73 0 my ($self) = @_;
74 0 return shift @{$self->{ contents }};
75 }
76  
77 0 ▶sub SPLICE {
Subroutine SPLICE: not called CC=3 SCAR=24.8
78 0 my ($self, $offset, $length, @l) = @_;
79 0 ▶ $offset = 0 unless defined $offset;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $offset 0 0 0
80 0 ▶ $length = $self->FETCHSIZE() - $offset unless defined $length;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $length 0 0 0
81 0 return splice @{$self->{ contents }}, $offset, $length, map { _checktype($_) } @l;
82 }
83  
84 222 ▶sub _checktype {
Subroutine _checktype: called CC=10 SCAR=44.5
85 222 my ($v) = @_;
86 222 ▶ return $v if ref($v) eq 'Net::IPAddress::Util::Range';
Branch: 1 branch
BranchTrueFalseTotal
if ref $v eq "Net::IPAddress::Util::Range" 222 0 222
87 0 ▶ if (ref($v) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $v eq "HASH") 0 0 0
88 0 eval { $v = Net::IPAddress::Util::Range->new($v) };
89 }
90 0 ▶ if (!ref($v) or ref($v) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $v or ref $v eq "ARRAY") 0 0 0
Condition0%0/3
not ref $v or ref $v eq "ARRAY"
l!l&&r!l&&!r
000
MC/DC0%0/2
not ref $v or ref $v eq "ARRAY"
not ref $v ref $v eq "ARRAY"
Truth table0%0/3
not(A) or B
A= not ref $vB= ref $v eq "ARRAY"
ABresult
1X1
011
000
91 0 eval { $v = Net::IPAddress::Util->new($v) };
92 }
93 0 ▶ if (ref($v) eq 'Net::IPAddress::Util') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $v eq "Net::IPAddress::Util") 0 0 0
94 0 $v = Net::IPAddress::Util::Range->new({ ip => $v });
95 }
96 0 ▶ if (!defined($v) or ref($v) ne 'Net::IPAddress::Util::Range') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $v or ref $v ne "Net::IPAddress::Util::Range") 0 0 0
Condition0%0/3
not defined $v or ref $v ne "Net::IPAddress::Util::Range"
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $v or ref $v ne "Net::IPAddress::Util::Range"
not defined $v ref $v ne "Net::IPAddress::Util::Range"
Truth table0%0/3
not(A) or B
A= not defined $vB= ref $v ne "Net::IPAddress::Util::Range"
ABresult
1X1
011
000
97 0 ▶ my $disp = defined($v) ? (ref($v) || 'bare scalar') : 'undef()';
Branch: 1 branch
BranchTrueFalseTotal
defined $v ? : 0 0 0
Condition0%0/2
ref $v or "bare scalar"
l!l
00
MC/DC0%0/1
ref $v or "bare scalar"
ref $v
Truth table0%0/2
A
A= ref $v
Aresult
11
00
98 0 confess("Invalid data type ($disp)");
99 }
100 0 return $v;
101 }
102  
103 5 1;
104  
105 __END__
↑ Summary Util.pm »