Farly/Transport/Protocol.pm

filter: Statementstmt 100% 37 / 37 Branchbran 68.7% 11 / 16 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 11 / 11 Podpod 85.7% 6 / 7 totaltotal 87.6% 71 / 81 CC 11 SCAR 10.8
CC
11
Cov
88%
new
5.9
contains
3.0
intersects
3.0
CRAP 2.9
« Farly/IPv4/Address.pm ↑ Summary Farly/Remove/Rule.pm »
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
BranchTrueFalseTotal
unless defined $protocol 0 471 471
14
15 471 $protocol =~ s/\s+//g;
16
17 471 ▶ confess "$protocol is not a number"
Branch: 1 branch
BranchTrueFalseTotal
unless $protocol =~ /^\d+$/ 0 471 471
18 unless ( $protocol =~ /^\d+$/ );
19
20 471 ▶ confess "invalid protocol $protocol"
Branch: 1 branch
BranchTrueFalseTotal
unless $protocol >= 0 and $protocol <= 255 0 471 471
Condition33%1/3
$protocol >= 0 and $protocol <= 255
!ll&&!rl&&r
00471
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
ABresult
0X0
100
111
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
BranchTrueFalseTotal
if ($other->isa("Farly::Transport::Protocol")) 535 133 668
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
BranchTrueFalseTotal
if ($other->isa("Farly::Transport::Protocol")) 23 0 23
47
48 23 ▶ if ( $self->protocol() == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->protocol == 0) 4 19 23
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
BranchTrueFalseTotal
if ($self->contains($other) or $other->contains($self)) 2 1 3
Condition100%3/3
$self->contains($other) or $other->contains($self)
l!l&&r!l&&!r
111
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)
ABresult
1X1
011
000
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
BranchTrueFalseTotal
if ($other->isa("Farly::Transport::Protocol")) 12 0 12
68 12 return $self->protocol() <=> $other->protocol();
69 }
70 }
71
72 17 1;
73 __END__
« Farly/IPv4/Address.pm ↑ Summary Farly/Remove/Rule.pm »