Romani/Query/Function/Count.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 62 CC 3 SCAR 12.0
CC
3
Cov
0%
new
6.0
add
6.0
get_distinct
2.0
CRAP 3.3
1  
2 package DBIx::Romani::Query::Function::Count;
3 use base qw(DBIx::Romani::Query::Function);
4  
5 use DBIx::Romani::Query::SQL::Column;
6 use DBIx::Romani::Query::SQL::Literal;
7 use strict;
8  
9 sub new
10 {
11 my $class = shift;
12 my $args = shift;
13  
14 my $distinct = 0;
15
16 if ( ref($args) eq 'HASH' )
17 {
18 $distinct = $args->{distinct} || $distinct;
19 }
20
21 my $self = $class->SUPER::new();
22 $self->{distinct} = $distinct;
23  
24 bless $self, $class;
25 return $self;
26 }
27  
28 sub get_distinct { return shift->{distinct}; }
29  
30 sub set_distinct
31 {
32 my ($self, $distinct) = @_;
33 $self->{distinct} = $distinct;
34 }
35  
36 sub add
37 {
38 my ($self, $value) = @_;
39
40 if ( scalar @{$self->get_arguments()} == 1 )
41 {
42 die "Cannot set more than one argument for the COUNT function";
43 }
44  
45 $self->SUPER::add( $value );
46 }
47  
48 sub visit
49 {
50 my ($self, $visitor) = @_;
51 return $visitor->visit_function_count( $self );
52 }
53  
54 sub clone
55 {
56 my $self = shift;
57  
58 my $add;
59 $add = DBIx::Romani::Query::Function::Count->new({ distinct => $self->get_distinct() });
60 $add->copy_arguments( $self );
61  
62 return $add;
63 }
64  
65 1;
66