Pager.pm

filter: Statementstmt 97.0% 33 / 34 Branchbran 75.0% 6 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 3 totaltotal 84.2% 48 / 57 CC 6 SCAR 11.8
CC
6
Cov
91%
retrieve
6.1
get_total_entries
2.0
BEGIN
1.0
CRAP 3.3
« Mixin/SearchWithPager.pm ↑ Summary Pager/Logic/PlusOne.pm »
1 package DBIx::Skinny::Pager;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use base 'DBIx::Skinny::SQL';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use DBIx::Skinny::Pager::Page::Default;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 ▶use DBIx::Skinny::Pager::ResultSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 7 ▶use Class::Accessor::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 7 our $VERSION = '0.11';
11  
12 7 Class::Accessor::Lite->mk_accessors(qw/page/);
13  
14 0 ▶sub get_total_entries {
Subroutine get_total_entries: not called CC=1 SCAR=6.9
Pod undocumented
15 0 die "please override";
16 }
17  
18 3 ▶sub pager_class {
Subroutine pager_class: called CC=1 SCAR=0.0
Pod undocumented
19 3 "DBIx::Skinny::Pager::Page::Default";
20 }
21  
22 6 ▶sub retrieve {
Subroutine retrieve: called CC=6 SCAR=18.1
Pod undocumented
23 6 my $self = shift;
24 6 ▶ Carp::croak("limit not found") unless defined($self->limit);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->limit 0 6 6
25 6 ▶ unless ( defined($self->offset) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->offset) 2 4 6
26 2 ▶ Carp::croak("limit or page not found") unless defined($self->page);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->page 0 2 2
27 2 ▶ $self->offset($self->limit * ( (int($self->page) || 1) - 1) );
Condition50%1/2
int $self->page || 1
l!l
20
MC/DC0%0/1
int $self->page || 1
int $self->page
Truth table50%1/2
A
A= int $self->page
Aresult
11
00
28 }
29  
30 6 my $iter = $self->SUPER::retrieve(@_);
31 6 my $total_entries = $self->get_total_entries($iter);
32 6 my $pager = $self->pager_class->new($total_entries, $self->limit, ( $self->offset / $self->limit) + 1);
33  
34 6 ▶ if ( wantarray ) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 4 2 6
35 4 return ( $iter, $pager );
36 } else {
37 2 return DBIx::Skinny::Pager::ResultSet->new(
38 iterator => $iter,
39 pager => $pager,
40 );
41 }
42 }
43  
44 7 1;
45 __END__
« Mixin/SearchWithPager.pm ↑ Summary Pager/Logic/PlusOne.pm »