DBomb/Query/OrderBy.pm

filter: Statementstmt 66.6% 26 / 39 Branchbran 41.6% 5 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 40.0% 2 / 5 totaltotal 61.5% 40 / 65 CC 7 SCAR 14.8
CC
7
Cov
61%
sql
12.0
append
4.7
init
3.0
CRAP 4.4
« DBomb/Meta/Key.pm ↑ Summary DBomb/Meta/OneToMany.pm »
1 package DBomb::Query::OrderBy;
2  
3 =head1 NAME
4  
5 DBomb::Query::OrderBy - An ORDER BY 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.4 $';
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(names)],
19 'boolean' => [qw(is_desc)],
20 12 ;
21  
22 ## new OrderBy([cols,...])
23 ## new OrderBy(cols,...)
24 4 ▶sub init {
Subroutine init: called CC=3 SCAR=11.0
Pod undocumented
25 4 my $self = shift;
26 4 assert(@_ > 0, 'valid parameters');
27 4 ▶ assert(@_ == 1 ? (ref($_[0])? ref($_[0]) eq 'ARRAY' : 1) : 1, 'valid parameters');
Branch: 2 branches
BranchTrueFalseTotal
@_ == 1 ? : 1 3 4
ref $_[0] ? : 0 1 1
28 4 $self->names([]);
29 4 $self->append(@_);
30 }
31  
32 4 ▶sub append {
Subroutine append: called CC=3 SCAR=15.4
Pod undocumented
33 4 my $self = shift;
34  
35 4 ▶ if (UNIVERSAL::isa($_[0],__PACKAGE__)){
Branch: 2 branches
BranchTrueFalseTotal
if (UNIVERSAL::isa($_[0], __PACKAGE__)) { } 0 4 4
elsif (ref $_[0] eq 'ARRAY') { } 0 4 4
36 0 push @{$self->names}, @{$_[0]->names};
37 }
38 elsif (ref($_[0]) eq 'ARRAY'){
39 0 push @{$self->names}, @{$_->[0]}
40 }
41 else {
42 4 push @{$self->names}, @_;
43 }
44 }
45  
46 0 ▶sub asc {
Subroutine asc: not called CC=1 SCAR=6.9
Pod documented
47 0 my $self = shift;
48 0 assert(@_ == 0, 'asc takes no arguments');
49 0 $self->is_desc(0);
50 }
51  
52 2 ▶sub desc {
Subroutine desc: called CC=1 SCAR=0.0
Pod documented
53 2 my $self = shift;
54 2 assert(@_ == 0, 'desc takes no arguments');
55 2 $self->is_desc(1);
56 }
57  
58 0 ▶sub sql {
Subroutine sql: not called CC=3 SCAR=24.8
Pod undocumented
59 0 my ($self, $dbh) = @_;
60 0 my $names = $self->names;
61 0 ▶ return '' unless @$names;
Branch: 1 branch
BranchTrueFalseTotal
unless @$names 0 0 0
62 0 ▶ return join(",", @$names) . ($self->is_desc ? ' DESC ' : ' ASC ');
Branch: 1 branch
BranchTrueFalseTotal
$self->is_desc ? : 0 0 0
63 }
64  
65  
66 12 1;
67 __END__
« DBomb/Meta/Key.pm ↑ Summary DBomb/Meta/OneToMany.pm »