OpenSky/Response.pm

filter: Statementstmt 67.4% 60 / 89 Branchbran 30.4% 14 / 46 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 64.2% 9 / 14 Podpod 85.7% 6 / 7 totaltotal 57.0% 89 / 156 CC 24 SCAR 18.9
CC
24
Cov
55%
_create_response_iterator
12.0
_empty_response
12.0
first
12.0
CRAP 6.6
« OpenSky.pm ↑ Summary OpenSky/Utils/Iterator.pm »
1 package WebService::OpenSky::Response;
2  
3 # ABSTRACT: A class representing a response from the OpenSky Network API
4  
5 8 ▶use WebService::OpenSky::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use WebService::OpenSky::Utils::Iterator;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use WebService::OpenSky::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
8 ArrayRef
9 Bool
10 HashRef
11 InstanceOf
12 Route
13 8 );
14  
15 8 our $VERSION = '0.5';
16  
17 6 ▶param raw_response => (
Branch: 1 branch
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method (anon) (expected 1, got ' . @_ . ')') 0 6 6
18 isa => ArrayRef | HashRef,
19 6 ▶ default => method() { $self->_empty_response },
Subroutine __ANON__: called CC=3 SCAR=11.1
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 and Function::Parameters::_croak('Too many arguments for method (anon) (expected 1, got ' . @_ . ')') 0 6 6
20 );
21  
22 8 param route => (
23 isa => Route,
24 );
25  
26 8 param query => (
27 isa => HashRef,
28 );
29  
30 8 field _iterator => (
31 is => 'rw',
32 isa => InstanceOf ['WebService::OpenSky::Utils::Iterator'],
33 writer => '_set_iterator',
34 init_arg => undef,
35 );
36  
37 8 field _inflated => (
38 is => 'rw',
39 isa => Bool,
40 default => 0,
41 init_arg => undef,
42 );
43  
44 13 ▶method BUILD(@args) {
Subroutine BUILD: called CC=3 SCAR=11.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method BUILD (expected 1, got ' . @_ . ')') 0 13 13
45 13 ▶ if ( !$self->raw_response ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->raw_response) 0 13 13
46 0 $self->raw_response( $self->_empty_response );
47 }
48 8 }
49  
50 98 ▶method _inflate() {
Subroutine _inflate: called CC=4 SCAR=14.0
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method _inflate (expected 1, got ' . @_ . ')') 0 98 98
@_ > 1 and Function::Parameters::_croak('Too many arguments for method _inflate (expected 1, got ' . @_ . ')') 0 98 98
51 98 ▶ return if $self->_inflated;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_inflated 86 12 98
52 12 my $iterator = WebService::OpenSky::Utils::Iterator->new( rows => $self->_create_response_objects );
53 12 $self->_set_iterator($iterator);
54 12 $self->_inflated(1);
55 8 }
56  
57 0 ▶method _create_response_iterator() {
Subroutine _create_response_iterator: not called CC=3 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method _create_response_iterator (expected 1, got ' . @_ . ')') 0 0 0
@_ > 1 and Function::Parameters::_croak('Too many arguments for method _create_response_iterator (expected 1, got ' . @_ . ')') 0 0 0
58 0 croak 'This method must be implemented by a subclass';
59 8 }
60  
61 0 ▶method _empty_response() {
Subroutine _empty_response: not called CC=3 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method _empty_response (expected 1, got ' . @_ . ')') 0 0 0
@_ > 1 and Function::Parameters::_croak('Too many arguments for method _empty_response (expected 1, got ' . @_ . ')') 0 0 0
62 0 croak 'This method must be implemented by a subclass';
63 8 }
64  
65 50 ▶method iterator() {
Subroutine iterator: called CC=3 SCAR=11.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method iterator (expected 1, got ' . @_ . ')') 0 50 50
@_ > 1 and Function::Parameters::_croak('Too many arguments for method iterator (expected 1, got ' . @_ . ')') 0 50 50
66 50 $self->_inflate;
67 50 return $self->_iterator;
68 8 }
69  
70 36 ▶method next() { ## no critic (Subroutines::ProhibitBuiltinHomonyms)
Subroutine next: called CC=3 SCAR=11.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method next (expected 1, got ' . @_ . ')') 0 36 36
@_ > 1 and Function::Parameters::_croak('Too many arguments for method next (expected 1, got ' . @_ . ')') 0 36 36
71 36 $self->_inflate;
72 36 return $self->iterator->next;
73 8 }
74  
75 0 ▶method first() {
Subroutine first: not called CC=3 SCAR=24.8
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method first (expected 1, got ' . @_ . ')') 0 0 0
@_ > 1 and Function::Parameters::_croak('Too many arguments for method first (expected 1, got ' . @_ . ')') 0 0 0
76 0 $self->_inflate;
77 0 return $self->iterator->first;
78 8 }
79  
80 0 ▶method reset() { ## no critic (Subroutines::ProhibitBuiltinHomonyms)
Subroutine reset: not called CC=3 SCAR=24.8
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method reset (expected 1, got ' . @_ . ')') 0 0 0
@_ > 1 and Function::Parameters::_croak('Too many arguments for method reset (expected 1, got ' . @_ . ')') 0 0 0
81 0 $self->_inflate;
82 0 return $self->iterator->reset;
83 8 }
84  
85 0 ▶method all() {
Subroutine all: not called CC=3 SCAR=24.8
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method all (expected 1, got ' . @_ . ')') 0 0 0
@_ > 1 and Function::Parameters::_croak('Too many arguments for method all (expected 1, got ' . @_ . ')') 0 0 0
86 0 $self->_inflate;
87 0 return $self->iterator->all;
88 8 }
89  
90 12 ▶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 12 12
@_ > 1 and Function::Parameters::_croak('Too many arguments for method count (expected 1, got ' . @_ . ')') 0 12 12
91 12 $self->_inflate;
92 12 return $self->iterator->count;
93 }
94  
95 __END__
« OpenSky.pm ↑ Summary OpenSky/Utils/Iterator.pm »