Farly/IPv4/Address.pm

filter: Statementstmt 95.0% 38 / 40 Branchbran 70.0% 7 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 86.6% 13 / 15 Podpod 100% 10 / 10 totaltotal 86.2% 69 / 80 CC 7 SCAR 11.8
CC
7
Cov
87%
new
7.4
start
2.0
end
2.0
CRAP 3.2
« Farly/IPv4/ICMPType.pm ↑ Summary Farly/Transport/Protocol.pm »
1 package Farly::IPv4::Address;
2
3 19 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 19 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 19 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 19 ▶use Farly::IPv4::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
8
9 19 our @ISA = qw(Farly::IPv4::Object);
10 19 our $VERSION = '0.26';
11
12 626 ▶sub new {
Subroutine new: called CC=7 SCAR=20.1
Pod documented
13 626 my ( $class, $address ) = @_;
14
15 626 ▶ confess "IP address required"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $address 0 626 626
16 unless ( defined($address) );
17
18 626 ▶ carp "invalid constructor arguments"
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 2 0 626 626
19 if ( scalar(@_) > 2 );
20
21 626 $address =~ s/\s+//g;
22
23 626 ▶ if ( $address =~ /^((\d{1,3})((\.)(\d{1,3})){3})$/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($address =~ /^((\d{1,3})((\.)(\d{1,3})){3})$/) { } 463 163 626
elsif ($address =~ /^\d+$/) { } 161 2 163
24 463 $address = pack( "C4", split( /\./, $address ) );
25 }
26 elsif ( $address =~ /^\d+$/ ) {
27 161 $address = pack( "N", $address );
28 }
29 else {
30 2 confess "invalid address $address";
31 }
32
33 623 my $ip = bless( \$address, $class );
34
35 623 ▶ confess "invalid address $address"
Branch: 1 branch
BranchTrueFalseTotal
unless $ip->address >= 0 and $ip->address <= 4294967295 0 623 623
Condition33%1/3
$ip->address >= 0 and $ip->address <= 4294967295
!ll&&!rl&&r
00623
MC/DC0%0/2
$ip->address >= 0 and $ip->address <= 4294967295
$ip->address >= 0 $ip->address <= 4294967295
Truth table33%1/3
A and B
A= $ip->address >= 0B= $ip->address <= 4294967295
ABresult
0X0
100
111
36 unless ( $ip->address() >= 0 && $ip->address() <= 4294967295 );
37
38 623 return $ip;
39 }
40
41 3607 ▶sub address {
Subroutine address: called CC=1 SCAR=0.0
Pod documented
42 3607 return unpack( "N", ${ $_[0] } );
43 }
44
45 242 ▶sub inverse {
Subroutine inverse: called CC=1 SCAR=0.0
Pod documented
46 242 return ~$_[0]->address() & 4294967295;
47 }
48
49 296 ▶sub first {
Subroutine first: called CC=1 SCAR=0.0
Pod documented
50 296 return $_[0]->address();
51 }
52
53 166 ▶sub last {
Subroutine last: called CC=1 SCAR=0.0
Pod documented
54 166 return $_[0]->address();
55 }
56
57 0 ▶sub start {
Subroutine start: not called CC=1 SCAR=6.9
Pod documented
58 0 return Farly::IPv4::Address->new( $_[0]->address() );
59 }
60
61 0 ▶sub end {
Subroutine end: not called CC=1 SCAR=6.9
Pod documented
62 0 return Farly::IPv4::Address->new( $_[0]->address() );
63 }
64
65 433 ▶sub dottedDecimalFormat {
Subroutine dottedDecimalFormat: called CC=1 SCAR=0.0
Pod documented
66 433 return join( ".", unpack( 'C4', ${ $_[0] } ) );
67 }
68
69 433 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
70 433 return $_[0]->dottedDecimalFormat();
71 }
72
73 1 ▶sub iter {
Subroutine iter: called CC=1 SCAR=0.0
Pod documented
74 1 my @iter = ( Farly::IPv4::Range->new( $_[0]->first(), $_[0]->last() ) );
75 1 return @iter;
76 }
77
78 19 1;
79 __END__
« Farly/IPv4/ICMPType.pm ↑ Summary Farly/Transport/Protocol.pm »