Mongol/Roles/Pagination.pm

filter: Statementstmt 65.2% 15 / 23 Branchbran n/a Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 80.0% 4 / 5 Podpod 100% 1 / 1 totaltotal 52.6% 20 / 38 CC 4 SCAR 23.5
CC
4
Cov
52%
paginate
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 10.5
« Mongol.pm ↑ Summary Mongol/Roles/Relations.pm »
1 package Mongol::Roles::Pagination;
2  
3 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Mongol::Models::Page;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 PAGINATION_DEFAULT_START => 0,
9 PAGINATION_DEFAULT_ROWS => 10,
10 1 };
11  
12 1 requires 'count';
13 1 requires 'find';
14  
15 0 ▶sub paginate {
Subroutine paginate: not called CC=4 SCAR=30.0
Pod documented
16 0 my ( $class, $query, $start, $rows, $options ) = @_;
17  
18 0 ▶ $options ||= {};
Condition0%0/2
$options ||= {}
l!l
00
MC/DC0%0/1
$options ||= {}
$options
Truth table0%0/2
A
A= $options
Aresult
11
00
19 0 ▶ $options->{skip} = $start || PAGINATION_DEFAULT_START;
Condition0%0/2
$start || 0
l!l
00
MC/DC0%0/1
$start || 0
$start
Truth table0%0/2
A
A= $start
Aresult
11
00
20 0 ▶ $options->{limit} = $rows || PAGINATION_DEFAULT_ROWS;
Condition0%0/2
$rows || 10
l!l
00
MC/DC0%0/1
$rows || 10
$rows
Truth table0%0/2
A
A= $rows
Aresult
11
00
21  
22 0 my $total = $class->count( $query );
23 0 my @items = $class->find( $query, $options )
24 ->all();
25  
26 my $page = Mongol::Models::Page->new(
27 {
28 items => \@items,
29 total => $total,
30 start => $options->{skip},
31 rows => $options->{limit},
32 }
33 0 );
34  
35 0 return $page;
36 }
37  
38 1 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 1 1;
41  
42 __END__
« Mongol.pm ↑ Summary Mongol/Roles/Relations.pm »