Pager/Logic/PlusOne.pm

filter: Statementstmt 100% 30 / 30 Branchbran 75.0% 3 / 4 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 91.4% 43 / 47 CC 4 SCAR 7.9
CC
4
Cov
97%
get_total_entries
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« Pager.pm ↑ Summary Mixin/Pager.pm »
1 package DBIx::Skinny::Pager::Logic::PlusOne;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use base qw(DBIx::Skinny::Pager);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use DBIx::Skinny::Pager::Page::PlusOne;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶sub as_sql {
Subroutine as_sql: called CC=1 SCAR=0.0
Pod undocumented
8 4 my $self = shift;
9 4 my $original_limit = $self->limit;
10 4 $self->limit($original_limit + 1);
11 4 my $result = $self->SUPER::as_sql;
12 4 $self->limit($original_limit);
13 4 return $result;
14 }
15  
16 3 ▶sub pager_class {
Subroutine pager_class: called CC=1 SCAR=0.0
Pod undocumented
17 3 "DBIx::Skinny::Pager::Page::PlusOne";
18 }
19  
20 3 ▶sub get_total_entries {
Subroutine get_total_entries: called CC=4 SCAR=13.9
Pod undocumented
21 3 my ($self, $iter) = @_;
22 3 my $has_next;
23 # XXX: iterがno cacheの場合はうまくいかないが、
24 # ここはPagerで拡張したretrieve以外から呼ばれることは想定されていないので
25 # 大丈夫な気もする
26 3 ▶ if ( $iter->count > $self->limit ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter->count > $self->limit) 2 1 3
27 2 pop @{$iter->{_rows_cache}};
28 # for date2itr
29 2 ▶ if ( $iter->{data} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter->{"data"}) 2 0 2
30 2 pop @{$iter->{data}};
31 }
32 2 $has_next++;
33 }
34 3 ▶ return $self->offset + $self->limit + ( $has_next || 0 );
Condition100%2/2
$has_next || 0
l!l
21
MC/DC100%1/1
$has_next || 0
$has_next
Truth table100%2/2
A
A= $has_next
Aresult
11
00
35 }
36  
37 5 1;
38 __END__
« Pager.pm ↑ Summary Mixin/Pager.pm »