API/Utils/Iterator.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 5 / 5 totaltotal 100% 39 / 39 CC 2 SCAR 2.0
CC
2
Cov
100%
next
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« API/Types.pm ↑ Summary API/States.pm »
1 # ABSTARCT: Internal iterator class for OpenSky::API
2  
3 package OpenSky::API::Utils::Iterator;
4  
5 6 our $VERSION = '0.005';
6 6 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use OpenSky::API::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
8 ArrayRef
9 Defined
10 InstanceOf
11 PositiveOrZeroInt
12 6 );
13 6 ▶use experimental qw(signatures);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 6 has '_rows' => (
16 is => 'ro',
17 isa => ArrayRef [Defined],
18 init_arg => 'rows',
19 );
20  
21 6 has '_index' => (
22 is => 'rw',
23 writer => '_set_index',
24 isa => PositiveOrZeroInt,
25 default => 0,
26 );
27  
28 6 ▶sub first ($self) {
Subroutine first: called CC=1 SCAR=0.0
Pod documented
29 6 return $self->_rows->[0];
30 }
31  
32 8 ▶sub next ($self) {
Subroutine next: called CC=2 SCAR=6.9
Pod documented
33 8 my $i = $self->_index;
34 8 ▶ my $next = $self->_rows->[$i] or return;
Branch: 1 branch
BranchTrueFalseTotal
my $next = $self->_rows->[$i] or return 6 2 8
35 6 $self->_set_index( $i + 1 );
36 6 return $next;
37 }
38  
39 1 ▶sub reset ($self) {
Subroutine reset: called CC=1 SCAR=0.0
Pod documented
40 1 $self->_set_index(0);
41 1 return 1;
42 }
43  
44 2 ▶sub all ($self) {
Subroutine all: called CC=1 SCAR=0.0
Pod documented
45 2 return @{ $self->_rows };
46 }
47  
48 1 ▶sub count ($self) {
Subroutine count: called CC=1 SCAR=0.0
Pod documented
49 1 my @all = $self->all;
50 1 return scalar @all;
51 }
52  
53 6 __PACKAGE__->meta->make_immutable;
54  
55 __END__
« API/Types.pm ↑ Summary API/States.pm »