| 1 | package Farly::Transport::Protocol; | ||||||||||||||||||||||||||||
| 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 | 471 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=17.8
Pod
documented
| |||||||||||||||||||||||||||||
| 11 | 471 | my ( $class, $protocol ) = @_; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 471 | ▶ | confess "protocol number required" unless ( defined $protocol ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 471 | $protocol =~ s/\s+//g; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 471 | ▶ | confess "$protocol is not a number" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | unless ( $protocol =~ /^\d+$/ ); | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 471 | ▶ | confess "invalid protocol $protocol" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$protocol >= 0 and $protocol <= 255
MC/DC0%0/2
$protocol >= 0 and $protocol <= 255
$protocol >= 0
$protocol <= 255
Truth table33%1/3
A and B
A= $protocol >= 0B= $protocol <= 255
| |||||||||||||||||||||||||||||
| 21 | unless ( ( $protocol >= 0 && $protocol <= 255 ) ); | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 471 | return bless( \$protocol, $class ); | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1117 | ▶ | sub protocol { | ||||||||||||||||||||||||||
|
Subroutine
protocol: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 1117 | return ${ $_[0] }; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 204 | ▶ | sub as_string { | ||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | 204 | return ${ $_[0] }; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 668 | ▶ | sub equals { | ||||||||||||||||||||||||||
|
Subroutine
equals: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | 668 | my ( $self, $other ) = @_; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 668 | ▶ | if ( $other->isa('Farly::Transport::Protocol') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 535 | return $self->protocol() == $other->protocol(); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 23 | ▶ | sub contains { | ||||||||||||||||||||||||||
|
Subroutine
contains: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 23 | my ( $self, $other ) = @_; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 23 | ▶ | if ( $other->isa('Farly::Transport::Protocol') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 23 | ▶ | if ( $self->protocol() == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 4 | return 1; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 19 | 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 | 12 | ▶ | sub compare { | ||||||||||||||||||||||||||
|
Subroutine
compare: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 65 | 12 | my ( $self, $other ) = @_; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 12 | ▶ | if ( $other->isa('Farly::Transport::Protocol') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 12 | return $self->protocol() <=> $other->protocol(); | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 17 | 1; | |||||||||||||||||||||||||||
| 73 | __END__ | ||||||||||||||||||||||||||||