blib/lib/Class/DBI/AbstractSearch.pm

filter: Statementstmt 48.2% 14 / 29 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 33.9% 18 / 53 CC 9 SCAR 42.2
CC
9
Cov
30%
search_where
90.0
BEGIN
1.0
BEGIN
1.0
CRAP 67.8
↑ Summary
1 package Class::DBI::AbstractSearch;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use vars qw($VERSION @EXPORT);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 $VERSION = 0.07;
6  
7 1 require Exporter;
8 1 *import = \&Exporter::import;
9 1 @EXPORT = qw(search_where);
10  
11 1 ▶use SQL::Abstract::Limit;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 0 ▶sub search_where {
Subroutine search_where: not called CC=9 SCAR=45.0
Pod documented
14 0 my $class = shift;
15 0 ▶ my $where = (ref $_[0]) ? $_[0] : { @_ };
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
16 0 ▶ my $attr = (ref $_[0]) ? $_[1] : undef;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
17 0 ▶ my $order = ($attr) ? delete($attr->{order_by}) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$attr ? : 0 0 0
18 0 ▶ my $limit = ($attr) ? delete($attr->{limit}) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$attr ? : 0 0 0
19 0 ▶ my $offset = ($attr) ? delete($attr->{offset}) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$attr ? : 0 0 0
20  
21 # order is deprecated, but still backward compatible
22 0 ▶ if ($attr && exists($attr->{order})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr and exists $attr->{"order"}) 0 0 0
Condition0%0/3
$attr and exists $attr->{"order"}
!ll&&!rl&&r
000
MC/DC0%0/2
$attr and exists $attr->{"order"}
$attr exists $attr->{"order"}
Truth table0%0/3
A and B
A= $attrB= exists $attr->{"order"}
ABresult
0X0
100
111
23 0 $order = delete($attr->{order});
24 }
25  
26 0 ▶ $class->can('retrieve_from_sql') or do {
Branch: 1 branch
BranchTrueFalseTotal
$class->can("retrieve_from_sql") or do { require Carp; Carp::croak("$class should inherit from Class::DBI >= 0.90") } 0 0 0
27 0 require Carp;
28 0 Carp::croak("$class should inherit from Class::DBI >= 0.90");
29 };
30 0 my $sql = SQL::Abstract::Limit->new(%$attr);
31 0 my($phrase, @bind) = $sql->where($where, $order, $limit, $offset);
32 0 $phrase =~ s/^\s*WHERE\s*//i;
33 0 return $class->retrieve_from_sql($phrase, @bind);
34 }
35  
36 1 1;
37 __END__
↑ Summary