OpenSky/Utils/Iterator.pm

filter: Statementstmt 100% 44 / 44 Branchbran 54.5% 12 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 5 / 5 totaltotal 87.1% 68 / 78 CC 12 SCAR 11.2
CC
12
Cov
85%
next
4.0
first
3.1
reset
3.1
CRAP 3.1
« OpenSky/Response.pm ↑ Summary OpenSky/Response/FlightTrack.pm »
1 package WebService::OpenSky::Utils::Iterator;
2  
3 # ABSTRACT: Internal iterator class for WebService::OpenSky
4  
5 9 ▶use WebService::OpenSky::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use WebService::OpenSky::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
7 ArrayRef
8 Defined
9 InstanceOf
10 PositiveOrZeroInt
11 9 );
12  
13 9 our $VERSION = '0.5';
14  
15 9 param rows => (
16 isa => ArrayRef [Defined],
17 reader => '_rows',
18 );
19  
20 9 field '_index' => (
21 writer => '_set_index',
22 isa => PositiveOrZeroInt,
23 default => 0,
24 );
25  
26 8 ▶method first() {
Subroutine first: called CC=3 SCAR=11.3
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method first (expected 1, got ' . @_ . ')') 0 8 8
@_ > 1 and Function::Parameters::_croak('Too many arguments for method first (expected 1, got ' . @_ . ')') 0 8 8
27 8 return $self->_rows->[0];
28 9 }
29  
30 44 ▶method next() { ## no critic (Subroutines::ProhibitBuiltinHomonyms)
Subroutine next: called CC=4 SCAR=14.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method next (expected 1, got ' . @_ . ')') 0 44 44
@_ > 1 and Function::Parameters::_croak('Too many arguments for method next (expected 1, got ' . @_ . ')') 0 44 44
31 44 my $i = $self->_index;
32 44 ▶ my $next = $self->_rows->[$i] or return;
Branch: 1 branch
BranchTrueFalseTotal
my $next = $self->_rows->[$i] or return 36 8 44
33 36 $self->_set_index( $i + 1 );
34 36 return $next;
35 9 }
36  
37 1 ▶method reset() { ## no critic (Subroutines::ProhibitBuiltinHomonyms)
Subroutine reset: called CC=3 SCAR=11.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method reset (expected 1, got ' . @_ . ')') 0 1 1
@_ > 1 and Function::Parameters::_croak('Too many arguments for method reset (expected 1, got ' . @_ . ')') 0 1 1
38 1 $self->_set_index(0);
39 1 return 1;
40 9 }
41  
42 14 ▶method all() {
Subroutine all: called CC=3 SCAR=11.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method all (expected 1, got ' . @_ . ')') 0 14 14
@_ > 1 and Function::Parameters::_croak('Too many arguments for method all (expected 1, got ' . @_ . ')') 0 14 14
43 14 return @{ $self->_rows };
44 9 }
45  
46 13 ▶method count() {
Subroutine count: called CC=3 SCAR=11.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method count (expected 1, got ' . @_ . ')') 0 13 13
@_ > 1 and Function::Parameters::_croak('Too many arguments for method count (expected 1, got ' . @_ . ')') 0 13 13
47 13 my @all = $self->all;
48 13 return scalar @all;
49 }
50  
51 __END__
« OpenSky/Response.pm ↑ Summary OpenSky/Response/FlightTrack.pm »