DBomb/Query/Limit.pm

filter: Statementstmt 65.7% 23 / 35 Branchbran 37.5% 6 / 16 Conditioncond 40.0% 6 / 15 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 2 totaltotal 49.3% 40 / 81 CC 14 SCAR 27.7
CC
14
Cov
53%
sql
30.0
init
14.8
BEGIN
1.0
CRAP 15.9
« DBomb/Util.pm ↑ Summary DBomb/Query/Update.pm »
1 package DBomb::Query::Limit;
2  
3 =head1 NAME
4  
5 DBomb::Query::Limit - A LIMIT clause.
6  
7 =head1 SYNOPSIS
8  
9 =cut
10  
11 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 12 our $VERSION = '$Revision: 1.3 $';
14  
15 12 ▶use Carp::Assert;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 use Class::MethodMaker
17 12 ▶ 'new_with_init' => 'new',
Subroutine BEGIN: called CC=1 SCAR=0.0
18 'get_set' => [qw(offset max_rows)],
19 12 ;
20  
21 ## new Limit ()
22 ## new Limit ($max_rows)
23 ## new Limit ($offset,$max_rows)
24 ## new Limit (+{ offset =>, max_rows=>1})
25 3 ▶sub init {
Subroutine init: called CC=10 SCAR=27.0
Pod undocumented
26 3 my $self = shift;
27 3 $self->offset(0);
28 3 $self->max_rows(undef);
29 3 ▶ return $self unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 3 3
30  
31 3 ▶ assert( (@_ == 1 && (ref($_[0])? ref($_[0]) eq 'HASH' : 1))
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 2 2
Condition50%6/12
@_ == 1 && (ref $_[0] ? ref $_[0] eq 'HASH' : 1) || @_ == 2 && !ref($_[0]) && !ref($_[1])
l!l&&r!l&&!r
210
@_ == 1 and ref $_[0] ? ref $_[0] eq "HASH" : 1
!ll&&!rl&&r
102
@_ == 2 and not ref $_[0] and not ref $_[1]
!ll&&!rl&&r
001
@_ == 2 and not ref $_[0]
!ll&&!rl&&r
001
MC/DC0%0/5
@_ == 1 && (ref $_[0] ? ref $_[0] eq 'HASH' : 1) || @_ == 2 && !ref($_[0]) && !ref($_[1])
@_ == 1 ref $_[0] ? ref $_[0] eq "HASH" : 1 @_ == 2 not ref $_[0] not ref $_[1]
Truth table22%2/9
A and B || C and not(D) and not(E)
A= @_ == 1B= ref $_[0] ? ref $_[0] eq "HASH" : 1C= @_ == 2D= not ref $_[0]E= not ref $_[1]
ABCDEresult
11XXX1
0X1111
101111
0X0XX0
0X10X0
0X1100
100XX0
1010X0
101100
32 || (@_ == 2 && !ref($_[0]) && ! ref($_[1])), 'parameter validation');
33  
34 3 ▶ if (ref($_[0]) eq 'HASH'){
Branch: 3 branches
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 3 3
elsif (@_ == 1) { } 2 1 3
elsif (@_ == 2) { } 1 0 1
35 0 $self->offset($_[0]->{'offset'});
36 0 $self->max_rows($_[0]->{'max_rows'});
37 }
38 elsif (@_==1){
39 2 $self->max_rows(shift);
40 }
41 elsif(@_ == 2){
42 1 $self->offset(shift);
43 1 $self->max_rows(shift);
44 }
45 }
46  
47 0 ▶sub sql {
Subroutine sql: not called CC=5 SCAR=34.0
Pod undocumented
48 0 my ($self, $dbh) = @_;
49 0 my($o,$m) = ($self->offset,$self->max_rows);
50 0 ▶ return '' unless defined($o) && defined($m);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $o and defined $m 0 0 0
Condition0%0/3
defined $o and defined $m
!ll&&!rl&&r
000
MC/DC0%0/2
defined $o and defined $m
defined $o defined $m
Truth table0%0/3
A and B
A= defined $oB= defined $m
ABresult
0X0
100
111
51  
52 0 assert(defined($m), 'valid max_rows');
53 0 ▶ assert($o >= 0, 'valid offset') if defined $o;
Branch: 1 branch
BranchTrueFalseTotal
if defined $o 0 0 0
54  
55 0 my $sql = " LIMIT ";
56 0 ▶ if(defined $o){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $o) 0 0 0
57 0 $sql .= " $o, ";
58 }
59 0 $sql .= "$m";
60 0 return $sql;
61 }
62  
63 12 1;
64 __END__
« DBomb/Util.pm ↑ Summary DBomb/Query/Update.pm »