API/Role/Iterator.pm

filter: Statementstmt 36.8% 14 / 38 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 57.1% 4 / 7 Podpod 100% 3 / 3 totaltotal 34.4% 21 / 61 CC 6 SCAR 22.0
CC
6
Cov
29%
get_all
20.0
get
6.0
list
6.0
CRAP 9.0
« API.pm ↑ Summary API/Role/Common.pm »
1 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Net::FreshBooks::API::Role::Iterator;
5 8 $Net::FreshBooks::API::Role::Iterator::VERSION = '0.24';
6 8 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use Data::Dump qw( dump );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 0 ▶sub get {
Subroutine get: not called CC=2 SCAR=17.9
Pod documented
10 0 my $self = shift;
11 0 ▶ my $args = shift || {};
Condition0%0/2
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
12 0 my $method = $self->method_string( 'get' );
13  
14 0 my $res = $self->send_request(
15 { _method => $method,
16 %$args,
17 }
18 );
19  
20 0 return $self->_fill_in_from_node( $res );
21 }
22  
23 0 ▶sub get_all {
Subroutine get_all: not called CC=4 SCAR=30.0
Pod documented
24  
25 0 my $self = shift;
26 0 ▶ my $args = shift || {};
Condition0%0/2
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
27  
28 # override any pagination
29 0 $args->{per_page} = 100;
30  
31 0 my @all = ();
32 0 my $per_page = 100;
33 0 my $page = 1;
34  
35 0 while ( 1 ) {
36  
37 0 my @subset = ();
38 0 $args->{page} = $page;
39 0 my $iter = $self->list( $args );
40  
41 0 ▶ while ( my $obj = $iter->next ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $obj = $iter->next) 0 0 0
42 0 push @subset, $obj;
43 }
44 0 push @all, @subset;
45  
46 0 ▶ last if scalar @subset < $per_page;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @subset < $per_page 0 0 0
47  
48 0 ++$page;
49 }
50  
51 0 return \@all;
52  
53 }
54  
55 0 ▶sub list {
Subroutine list: not called CC=2 SCAR=17.9
Pod documented
56 0 my $self = shift;
57 0 ▶ my $args = shift || {};
Condition0%0/2
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
58  
59 0 return Net::FreshBooks::API::Iterator->new(
60 { parent_object => $self,
61 args => $args,
62 }
63 );
64 }
65  
66 8 1;
67  
68 # ABSTRACT: Read-only roles
69  
70 __END__
« API.pm ↑ Summary API/Role/Common.pm »