SearchPage/Param.pm

filter: Statementstmt 10.0% 11 / 110 Branchbran 0.0% 0 / 70 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 15.0% 3 / 20 Podpod 0.0% 0 / 17 totaltotal 5.7% 14 / 245 CC 44 SCAR 59.0
CC
44
Cov
6%
new
812.0
auto_all
6.0
auto_null
6.0
CRAP 364.0
« SearchPage.pm ↑ Summary SearchPage/Files.pm »
1 package HTML::SearchPage::Param;
2  
3 1 our $VERSION = '0.05';
4  
5 # $Id: Param.pm,v 1.8 2007/09/19 21:30:18 canaran Exp $
6  
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 ###############
13 # CONSTRUCTOR #
14 ###############
15  
16 0 ▶sub new {
Subroutine new: not called CC=28 SCAR=67.0
Pod undocumented
17 0 my ($class, %raw_params) = @_;
18  
19 # Remove dashes from param names
20 my %params = map {
21 0 my $key = $_;
22 0 my $value = $raw_params{$key};
23 0 $key =~ s/^-//;
24 0 $key => $value;
25 } keys %raw_params;
26  
27 0 my $self = bless {}, $class;
28  
29 0 eval {
30 # Required params
31 my $sql_column = $params{sql_column}
32 0 ▶ or croak("A sql_column is required!");
Branch: 1 branch
BranchTrueFalseTotal
my $sql_column = $params{"sql_column"} or croak("A sql_column is required!") 0 0 0
33 0 $self->sql_column($sql_column);
34  
35 my $form_name = $params{form_name}
36 0 ▶ or croak("A form_name is required!");
Branch: 1 branch
BranchTrueFalseTotal
my $form_name = $params{"form_name"} or croak("A form_name is required!") 0 0 0
37 0 $self->form_name($form_name);
38  
39 my $param_type = $params{param_type}
40 0 ▶ or croak("A param_type is required!");
Branch: 1 branch
BranchTrueFalseTotal
my $param_type = $params{"param_type"} or croak("A param_type is required!") 0 0 0
41 0 ▶ croak("Invalid value for param_type ($param_type)!")
Branch: 1 branch
BranchTrueFalseTotal
unless $param_type eq "drop_down" or $param_type =~ /^scrolling_list:\d+$/ or $param_type =~ /^text:\d+$/ 0 0 0
Condition0%0/6
$param_type eq "drop_down" or $param_type =~ /^scrolling_list:\d+$/ or $param_type =~ /^text:\d+$/
l!l&&r!l&&!r
000
$param_type eq "drop_down" or $param_type =~ /^scrolling_list:\d+$/
l!l&&r!l&&!r
000
MC/DC0%0/3
$param_type eq "drop_down" or $param_type =~ /^scrolling_list:\d+$/ or $param_type =~ /^text:\d+$/
$param_type eq "drop_down" $param_type =~ /^scrolling_list:\d+$/ $param_type =~ /^text:\d+$/
Truth table0%0/4
A or B or C
A= $param_type eq "drop_down"B= $param_type =~ /^scrolling_list:\d+$/C= $param_type =~ /^text:\d+$/
ABCresult
1XX1
01X1
0011
0000
42 unless ($param_type eq 'drop_down'
43 or $param_type =~ /^scrolling_list:\d+$/
44 or $param_type =~ /^text:\d+$/);
45 0 $self->param_type($param_type);
46  
47 0 my $param_list = [];
48 0 ▶ if (defined $params{param_list} && ref $params{param_list}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $params{'param_list'} and ref $params{'param_list'}) { } 0 0 0
elsif (defined $params{'param_list'}) { } 0 0 0
Condition0%0/3
defined $params{"param_list"} and ref $params{"param_list"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $params{"param_list"} and ref $params{"param_list"}
defined $params{"param_list"} ref $params{"param_list"}
Truth table0%0/3
A and B
A= defined $params{"param_list"}B= ref $params{"param_list"}
ABresult
0X0
100
111
49 0 $param_list = $params{param_list};
50 }
51 elsif (defined $params{param_list}) {
52 0 $param_list = [$params{param_list}];
53 }
54
55 0 my $valid_param_count = 0;
56 0 ▶ if (@$param_list) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$param_list) 0 0 0
57 0 foreach my $value (@$param_list) {
58 0 ▶ next unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
59 0 $valid_param_count++;
60 0 ▶ croak("Invalid param_list value ($value)!")
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^DISTINCT:/ or $value =~ /^([^:]+):([^:]+)$/ or $value =~ /^([^:]+)$/ 0 0 0
Condition0%0/6
$value =~ /^DISTINCT:/ or $value =~ /^([^:]+):([^:]+)$/ or $value =~ /^([^:]+)$/
l!l&&r!l&&!r
000
$value =~ /^DISTINCT:/ or $value =~ /^([^:]+):([^:]+)$/
l!l&&r!l&&!r
000
MC/DC0%0/3
$value =~ /^DISTINCT:/ or $value =~ /^([^:]+):([^:]+)$/ or $value =~ /^([^:]+)$/
$value =~ /^DISTINCT:/ $value =~ /^([^:]+):([^:]+)$/ $value =~ /^([^:]+)$/
Truth table0%0/4
A or B or C
A= $value =~ /^DISTINCT:/B= $value =~ /^([^:]+):([^:]+)$/C= $value =~ /^([^:]+)$/
ABCresult
1XX1
01X1
0011
0000
61 unless (
62 $value =~ /^DISTINCT:/
63 or $value =~ /^([^:]+):([^:]+)$/ # space is allowed
64 or $value =~ /^([^:]+)$/ # space is allowed
65 );
66 }
67 }
68  
69 # *** Disabled; now handled by SearchPage.pm ***
70 # if (!$valid_param_count && $self->param_type !~ /^text:\d+$/) {
71 # croak("Valid param_list values are required!");
72 # }
73  
74 0 $self->param_list($param_list);
75  
76 # Optional params
77 0 $self->auto_all($params{auto_all});
78  
79 0 $self->auto_null($params{auto_null});
80  
81 0 $self->case_sensitive($params{case_sensitive});
82  
83 0 $self->disabled($params{disabled});
84  
85 0 $self->exact($params{exact});
86  
87 0 ▶ my $label = $params{label} ? $params{label} : 'Unknown Field';
Branch: 1 branch
BranchTrueFalseTotal
$params{'label'} ? : 0 0 0
88 0 $self->label($label);
89  
90 0 $self->numerical($params{numerical});
91  
92 0 my $operator_default = $params{operator_default};
93 0 ▶ if ($operator_default) {
Branch: 1 branch
BranchTrueFalseTotal
if ($operator_default) 0 0 0
94 0 ▶ croak("Invalid operator_default ($operator_default)!")
Branch: 1 branch
BranchTrueFalseTotal
unless $operator_default =~ /^([^\s:]+)$/ 0 0 0
95 unless ($operator_default =~ /^([^\s:]+)$/);
96 }
97 0 $self->operator_default($operator_default);
98  
99 0 $self->operator_display($params{operator_display});
100  
101 my $operator_list =
102 0 ▶ $params{operator_list} ? $params{operator_list} : ['=:equals to'];
Branch: 1 branch
BranchTrueFalseTotal
$params{'operator_list'} ? : 0 0 0
103 0 ▶ if ($operator_list) {
Branch: 1 branch
BranchTrueFalseTotal
if ($operator_list) 0 0 0
104 0 foreach my $value (@$operator_list) {
105 0 ▶ next unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
106 0 ▶ croak("Invalid operator_list value ($value)!")
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^([^\s:]+):([^:]+)$/ or $value =~ /^([^\s:]+)$/ 0 0 0
Condition0%0/3
$value =~ /^([^\s:]+):([^:]+)$/ or $value =~ /^([^\s:]+)$/
l!l&&r!l&&!r
000
MC/DC0%0/2
$value =~ /^([^\s:]+):([^:]+)$/ or $value =~ /^([^\s:]+)$/
$value =~ /^([^\s:]+):([^:]+)$/ $value =~ /^([^\s:]+)$/
Truth table0%0/3
A or B
A= $value =~ /^([^\s:]+):([^:]+)$/B= $value =~ /^([^\s:]+)$/
ABresult
1X1
011
000
107 unless ($value =~ /^([^\s:]+):([^:]+)$/
108 or $value =~ /^([^\s:]+)$/);
109 }
110 }
111 0 $self->operator_list($operator_list);
112  
113 0 my $param_default = $params{param_default};
114 0 ▶ if ($param_default) {
Branch: 1 branch
BranchTrueFalseTotal
if ($param_default) 0 0 0
115 0 ▶ croak("Invalid param_default value ($param_default)!")
Branch: 1 branch
BranchTrueFalseTotal
unless $param_default =~ /^([^:]+)$/ 0 0 0
116 unless ($param_default =~ /^([^:]+)$/); # space is allowed
117 }
118 0 $self->param_default($param_default);
119  
120 0 $self->rank($params{rank});
121  
122 };
123  
124 0 ▶ return $@ ? undef: $self;
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 0 0 0
125 }
126  
127 ###################
128 # GET/SET METHODS #
129 ###################
130  
131 0 ▶sub auto_all {
Subroutine auto_all: not called CC=2 SCAR=17.9
Pod undocumented
132 0 my ($self, $value) = @_;
133 0 ▶ $self->{auto_all} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
134 0 return $self->{auto_all};
135 }
136  
137 0 ▶sub auto_null {
Subroutine auto_null: not called CC=2 SCAR=17.9
Pod undocumented
138 0 my ($self, $value) = @_;
139 0 ▶ $self->{auto_null} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
140 0 return $self->{auto_null};
141 }
142  
143 0 ▶sub case_sensitive {
Subroutine case_sensitive: not called CC=2 SCAR=17.9
Pod undocumented
144 0 my ($self, $value) = @_;
145 0 ▶ $self->{case_sensitive} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
146 0 return $self->{case_sensitive};
147 }
148  
149 0 ▶sub disabled {
Subroutine disabled: not called CC=2 SCAR=17.9
Pod undocumented
150 0 my ($self, $value) = @_;
151 0 ▶ $self->{disabled} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
152 0 return $self->{disabled};
153 }
154  
155 0 ▶sub exact {
Subroutine exact: not called CC=2 SCAR=17.9
Pod undocumented
156 0 my ($self, $value) = @_;
157 0 ▶ $self->{exact} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
158 0 return $self->{exact};
159 }
160  
161 0 ▶sub form_name {
Subroutine form_name: not called CC=2 SCAR=17.9
Pod undocumented
162 0 my ($self, $value) = @_;
163 0 ▶ $self->{form_name} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
164 0 return $self->{form_name};
165 }
166  
167 0 ▶sub label {
Subroutine label: not called CC=2 SCAR=17.9
Pod undocumented
168 0 my ($self, $value) = @_;
169 0 ▶ $self->{label} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
170 0 return $self->{label};
171 }
172  
173 0 ▶sub numerical {
Subroutine numerical: not called CC=2 SCAR=17.9
Pod undocumented
174 0 my ($self, $value) = @_;
175 0 ▶ $self->{numerical} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
176 0 return $self->{numerical};
177 }
178  
179 0 ▶sub operator_default {
Subroutine operator_default: not called CC=2 SCAR=17.9
Pod undocumented
180 0 my ($self, $value) = @_;
181 0 ▶ $self->{operator_default} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
182 0 return $self->{operator_default};
183 }
184  
185 0 ▶sub operator_display {
Subroutine operator_display: not called CC=2 SCAR=17.9
Pod undocumented
186 0 my ($self, $value) = @_;
187 0 ▶ $self->{operator_display} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
188 0 return $self->{operator_display};
189 }
190  
191 0 ▶sub operator_list {
Subroutine operator_list: not called CC=2 SCAR=17.9
Pod undocumented
192 0 my ($self, $value) = @_;
193 0 ▶ $self->{operator_list} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
194 0 return $self->{operator_list};
195 }
196  
197 0 ▶sub param_default {
Subroutine param_default: not called CC=2 SCAR=17.9
Pod undocumented
198 0 my ($self, $value) = @_;
199 0 ▶ $self->{param_default} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
200 0 return $self->{param_default};
201 }
202  
203 0 ▶sub param_list {
Subroutine param_list: not called CC=2 SCAR=17.9
Pod undocumented
204 0 my ($self, $value) = @_;
205 0 ▶ $self->{param_list} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
206 0 return $self->{param_list};
207 }
208  
209 0 ▶sub param_type {
Subroutine param_type: not called CC=2 SCAR=17.9
Pod undocumented
210 0 my ($self, $value) = @_;
211 0 ▶ $self->{param_type} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
212 0 return $self->{param_type};
213 }
214  
215 0 ▶sub rank {
Subroutine rank: not called CC=2 SCAR=17.9
Pod undocumented
216 0 my ($self, $value) = @_;
217 0 ▶ $self->{rank} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
218 0 return $self->{rank};
219 }
220  
221 0 ▶sub sql_column {
Subroutine sql_column: not called CC=2 SCAR=17.9
Pod undocumented
222 0 my ($self, $value) = @_;
223 0 ▶ $self->{sql_column} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
224 0 return $self->{sql_column};
225 }
226  
227 1 1;
228  
229 __END__
« SearchPage.pm ↑ Summary SearchPage/Files.pm »