Romani/Query/Where.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 56 CC 4 SCAR 22.2
CC
4
Cov
0%
new
20.0
get_type
2.0
get_values
2.0
CRAP 9.2
1  
2 package DBIx::Romani::Query::Where;
3  
4 use strict;
5  
6 our $AND = 'AND';
7 our $OR = 'OR';
8  
9 sub new
10 {
11 my $class = shift;
12 my $args = shift;
13  
14 my $type;
15  
16 if ( ref($args) eq 'HASH' )
17 {
18 $type = $args->{type};
19 }
20 else
21 {
22 $type = $args;
23 }
24  
25 if ( not defined $type )
26 {
27 $type = $AND;
28 }
29  
30 if ( $type ne $AND and $type ne $OR )
31 {
32 die "Invalid SQL group type";
33 }
34  
35 my $self = {
36 type => $type,
37 values => [ ],
38 };
39  
40 bless $self, $class;
41 return $self;
42 }
43  
44 sub get_type { return shift->{type}; }
45 sub get_values { return shift->{values}; }
46  
47 sub add
48 {
49 my ($self, $val) = @_;
50 push @{$self->{values}}, $val;
51 }
52  
53 sub visit
54 {
55 my ($self, $visitor) = (shift, shift);
56 return $visitor->visit_where( $self, @_ );
57 }
58  
59 sub clone
60 {
61 my $self = shift;
62  
63 my $clone = DBIx::Romani::Query::Where->new({ type => $self->get_type() });
64 foreach my $value ( @{$self->get_values()} )
65 {
66 $clone->add( $value );
67 }
68
69 return $clone;
70 }
71  
72 1;
73