| 1 | package Farly::IPv4::ICMPType; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 17 | ▶ | use 5.008008; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 17 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 17 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 17 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 17 | our $VERSION = '0.26'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 92 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||
| 11 | 92 | my ( $class, $type ) = @_; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 92 | ▶ | confess "type number required" unless ( defined $type ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 92 | $type =~ s/\s+//g; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 92 | ▶ | confess "$type is not a number" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$type =~ /^\d+$/ or $type =~ /^-1$/
MC/DC0%0/2
$type =~ /^\d+$/ or $type =~ /^-1$/
$type =~ /^\d+$/
$type =~ /^-1$/
Truth table66%2/3
A or B
A= $type =~ /^\d+$/B= $type =~ /^-1$/
| |||||||||||||||||||||||||||||
| 18 | unless ( $type =~ /^\d+$/ || $type =~ /^-1$/ ); | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 92 | ▶ | confess "invalid type $type" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type >= -1 and $type <= 255
MC/DC0%0/2
$type >= -1 and $type <= 255
$type >= -1
$type <= 255
Truth table33%1/3
A and B
A= $type >= -1B= $type <= 255
| |||||||||||||||||||||||||||||
| 21 | unless ( ( $type >= -1 && $type <= 255 ) ); | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 92 | return bless( \$type, $class ); | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 66 | ▶ | sub type { | ||||||||||||||||||||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 66 | return ${ $_[0] }; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 21 | ▶ | sub as_string { | ||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | 21 | return ${ $_[0] }; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 23 | ▶ | sub equals { | ||||||||||||||||||||||||||
|
Subroutine
equals: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | 23 | my ( $self, $other ) = @_; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 23 | ▶ | if ( $other->isa('Farly::IPv4::ICMPType') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 15 | return $self->type() == $other->type(); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 16 | ▶ | sub contains { | ||||||||||||||||||||||||||
|
Subroutine
contains: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 16 | my ( $self, $other ) = @_; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 16 | ▶ | if ( $other->isa('Farly::IPv4::ICMPType') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 16 | ▶ | if ( $self->type() == -1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 3 | return 1; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 13 | return $self->equals($other); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 3 | ▶ | sub intersects { | ||||||||||||||||||||||||||
|
Subroutine
intersects: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 3 | my ( $self, $other ) = @_; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 3 | ▶ | if ( $self->contains($other) || $other->contains($self) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->contains($other) or $other->contains($self)
MC/DC100%2/2
$self->contains($other) or $other->contains($self)
$self->contains($other)
$other->contains($self)
Truth table100%3/3
A or B
A= $self->contains($other)B= $other->contains($self)
| |||||||||||||||||||||||||||||
| 60 | 2 | return 1; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 10 | ▶ | sub compare { | ||||||||||||||||||||||||||
|
Subroutine
compare: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 65 | 10 | my ( $self, $other ) = @_; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 10 | ▶ | if ( $other->isa('Farly::IPv4::ICMPType') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 10 | return $self->type() <=> $other->type(); | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 17 | 1; | |||||||||||||||||||||||||||
| 73 | __END__ | ||||||||||||||||||||||||||||