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