Catmandu/Hits.pm

filter: Statementstmt 100% 41 / 41 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 11 / 11 Podpod 14.2% 1 / 7 totaltotal 83.3% 55 / 66 CC 4 SCAR 4.8
CC
4
Cov
93%
more
3.2
each
2.0
BEGIN
1.0
CRAP 1.6
« Catmandu/Fix/collapse.pm ↑ Summary Catmandu/Error.pm »
1 package Catmandu::Hits;
2  
3 18 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 18 our $VERSION = '1.2025';
6  
7 18 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 18 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 18 has start => (is => 'ro', required => 1);
11 18 has limit => (is => 'ro', required => 1);
12 18 has total => (is => 'ro', required => 1);
13 18 has hits => (is => 'ro', required => 1);
14 18 has maximum_offset => (is => 'ro');
15  
16 18 with 'Catmandu::Iterable';
17 18 with 'Catmandu::Paged';
18  
19 1 ▶sub size {
Subroutine size: called CC=1 SCAR=0.0
Pod undocumented
20 1 scalar @{$_[0]->hits};
21 }
22  
23 1 ▶sub more {
Subroutine more: called CC=3 SCAR=11.6
Pod documented
24 1 my $self = $_[0];
25 1 my $start = $self->start;
26 1 my $limit = $self->limit;
27 1 my $max_offset = $self->maximum_offset;
28 1 ▶ return 0 if $max_offset && $start + $limit > $max_offset;
Branch: 1 branch
BranchTrueFalseTotal
if $max_offset and $start + $limit > $max_offset 0 1 1
Condition33%1/3
$max_offset and $start + $limit > $max_offset
!ll&&!rl&&r
100
MC/DC0%0/2
$max_offset and $start + $limit > $max_offset
$max_offset $start + $limit > $max_offset
Truth table33%1/3
A and B
A= $max_offsetB= $start + $limit > $max_offset
ABresult
0X0
100
111
29 1 $start + $limit < $self->total;
30 }
31  
32 1 ▶sub generator {
Subroutine generator: called CC=1 SCAR=0.0
Pod undocumented
33 1 my $self = $_[0];
34 1 my $hits = $self->hits;
35 1 my $i = 0;
36 1 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
37 1 $hits->[$i++];
38 1 };
39 }
40  
41 6 ▶sub to_array {
Subroutine to_array: called CC=1 SCAR=0.0
Pod undocumented
42 6 [@{$_[0]->hits}];
43 }
44  
45 1 ▶sub count {
Subroutine count: called CC=1 SCAR=0.0
Pod undocumented
46 1 scalar @{$_[0]->hits};
47 }
48  
49 1 ▶sub each {
Subroutine each: called CC=2 SCAR=6.9
Pod undocumented
50 1 my ($self, $cb) = @_;
51 1 my $hits = $self->hits;
52 1 for my $hit (@$hits) {
53 100 $cb->($hit);
54 }
55 1 $self->count;
56 }
57  
58 1 ▶sub first {
Subroutine first: called CC=1 SCAR=0.0
Pod undocumented
59 1 $_[0]->hits->[0];
60 }
61  
62 18 1;
63  
64 __END__
« Catmandu/Fix/collapse.pm ↑ Summary Catmandu/Error.pm »