Catmandu/Counter.pm

filter: Statementstmt 100% 22 / 22 Branchbran 50.0% 1 / 2 Conditioncond 75.0% 3 / 4 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 92.5% 37 / 40 CC 4 SCAR 6.1
CC
4
Cov
93%
dec_count
3.1
inc_count
2.0
BEGIN
1.0
CRAP 1.8
« Catmandu/Importer/CSV.pm ↑ Summary Catmandu/Fix/Bind/benchmark.pm »
1 package Catmandu::Counter;
2  
3 24 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 24 our $VERSION = '1.2025';
6  
7 24 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 24 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 84 ▶has count => (is => 'rwp', default => sub {0});
Subroutine __ANON__: called CC=1 SCAR=0.0
11  
12 359 ▶sub inc_count {
Subroutine inc_count: called CC=2 SCAR=6.9
Pod documented
13 359 my ($self, $n) = @_;
14 359 ▶ $n //= 1;
Condition100%2/2
$n //= 1
l!l
1358
MC/DC100%1/1
$n //= 1
$n
Truth table100%2/2
A
A= $n
Aresult
11
00
15 359 $self->_set_count($self->count + $n);
16 }
17  
18 2 ▶sub dec_count {
Subroutine dec_count: called CC=3 SCAR=11.4
Pod documented
19 2 my ($self, $n) = @_;
20 2 ▶ $n //= 1;
Condition50%1/2
$n //= 1
l!l
02
MC/DC0%0/1
$n //= 1
$n
Truth table50%1/2
A
A= $n
Aresult
11
00
21 2 my $count = $self->count - $n;
22 2 ▶ $self->_set_count($count > 0 ? $count : 0);
Branch: 1 branch
BranchTrueFalseTotal
$count > 0 ? : 0 2 2
23 }
24  
25 1 ▶sub reset_count {
Subroutine reset_count: called CC=1 SCAR=0.0
Pod documented
26 1 my $self = $_[0];
27 1 $self->_set_count(0);
28 }
29  
30 24 1;
31  
32 __END__
« Catmandu/Importer/CSV.pm ↑ Summary Catmandu/Fix/Bind/benchmark.pm »