Catmandu/Exporter/Count.pm

filter: Statementstmt 80.6% 25 / 31 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 76.0% 35 / 46 CC 4 SCAR 10.6
CC
4
Cov
76%
__ANON__
5.7
BEGIN
1.0
BEGIN
1.0
CRAP 2.9
« Catmandu/Exporter/CSV.pm ↑ Summary Catmandu/Fix/string.pm »
1 package Catmandu::Exporter::Count;
2  
3 1 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Catmandu::Util qw(is_hash_ref is_array_ref is_able);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '1.2025';
7  
8 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 with 'Catmandu::Exporter';
12  
13 # add is a noop since an Exporter is already a Counter
14 3 ▶sub add { }
Subroutine add: called CC=1 SCAR=0.0
Pod undocumented
15  
16 2 ▶sub commit {
Subroutine commit: called CC=1 SCAR=0.0
Pod undocumented
17 2 my $self = $_[0];
18 2 $self->fh->print($self->count . "\n");
19 }
20  
21 # optimize counting
22 1 ▶around add_many => sub {
Subroutine __ANON__: called CC=4 SCAR=17.4
23 1 my ($orig, $self, $many) = @_;
24  
25 1 ▶ if (is_hash_ref($many)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_hash_ref($many)) 0 1 1
26 0 $self->inc_count;
27 0 return 1;
28 }
29  
30 1 ▶ if (is_array_ref($many)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_array_ref($many)) 0 1 1
31 0 my $n = scalar @$many;
32 0 $self->inc_count($n);
33 0 return $n;
34 }
35  
36 1 ▶ if (is_able($many, 'count')) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_able($many, "count")) 1 0 1
37 1 my $n = $many->count;
38 1 $self->inc_count($n);
39 1 return $n;
40 }
41  
42 0 $orig->($self, $many);
43 1 };
44  
45 1 1;
46  
47 __END__
« Catmandu/Exporter/CSV.pm ↑ Summary Catmandu/Fix/string.pm »