Farly/Value/Integer.pm

filter: Statementstmt 100% 42 / 42 Branchbran 75.0% 9 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 15 / 15 Podpod 90.9% 10 / 11 totaltotal 95.0% 76 / 80 CC 7 SCAR 5.2
CC
7
Cov
94%
new
3.0
compare
2.0
gt
2.0
CRAP 1.7
« Farly/Transport/PortRange.pm ↑ Summary Farly/ASA/Builder.pm »
1 package Farly::Value::Integer;
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 122 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
11 122 my ( $class, $number ) = @_;
12
13 122 ▶ confess "integer required"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $number 1 121 122
14 unless defined($number);
15
16 121 $number =~ s/^\s+|\s+$//g;
17
18 121 ▶ confess "not an integer"
Branch: 1 branch
BranchTrueFalseTotal
unless $number =~ /^\d+$/ 1 120 121
19 unless ( $number =~ /^\d+$/ );
20
21 120 return bless( \$number, $class );
22 }
23
24 430 ▶sub number { return ${ $_[0] } }
Subroutine number: called CC=1 SCAR=0.0
Pod documented
25
26 121 ▶sub as_string { return ${ $_[0] } }
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
27
28 189 ▶sub equals {
Subroutine equals: called CC=2 SCAR=6.9
Pod documented
29 189 my ( $self, $other ) = @_;
30
31 189 ▶ if ( $other->isa('Farly::Value::Integer') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other->isa("Farly::Value::Integer")) 135 54 189
32 135 return $self->number() == $other->number();
33 }
34 }
35
36 1 ▶sub contains {
Subroutine contains: called CC=1 SCAR=0.0
Pod documented
37 1 my ( $self, $other ) = @_;
38 1 return $self->equals($other);
39 }
40
41 2 ▶sub intersects {
Subroutine intersects: called CC=1 SCAR=0.0
Pod documented
42 2 my ( $self, $other ) = @_;
43 2 return $self->equals($other);
44 }
45
46 71 ▶sub compare {
Subroutine compare: called CC=2 SCAR=7.1
Pod undocumented
47 71 my ( $self, $other ) = @_;
48
49 71 ▶ if ( $other->isa('Farly::Value::Integer') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other->isa("Farly::Value::Integer")) 71 0 71
50 71 return $self->number() <=> $other->number();
51 }
52 }
53
54 2 ▶sub gt {
Subroutine gt: called CC=2 SCAR=7.1
Pod documented
55 2 my ( $self, $other ) = @_;
56
57 2 ▶ if ( $other->isa('Farly::Value::Integer') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other->isa("Farly::Value::Integer")) 2 0 2
58 2 return $self->number() > $other->number();
59 }
60 }
61
62 1 ▶sub lt {
Subroutine lt: called CC=2 SCAR=7.1
Pod documented
63 1 my ( $self, $other ) = @_;
64
65 1 ▶ if ( $other->isa('Farly::Value::Integer') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other->isa("Farly::Value::Integer")) 1 0 1
66 1 return $self->number() < $other->number();
67 }
68 }
69
70 1 ▶sub incr {
Subroutine incr: called CC=1 SCAR=0.0
Pod documented
71 1 ${ $_[0] }++;
72 }
73
74 1 ▶sub decr {
Subroutine decr: called CC=1 SCAR=0.0
Pod documented
75 1 ${ $_[0] }--;
76 }
77
78 17 1;
79 __END__
« Farly/Transport/PortRange.pm ↑ Summary Farly/ASA/Builder.pm »