line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FormValidator::Simple::Data; |
2
|
23
|
|
|
23
|
|
23178
|
use strict; |
|
23
|
|
|
|
|
46
|
|
|
23
|
|
|
|
|
870
|
|
3
|
23
|
|
|
23
|
|
140
|
use Scalar::Util; |
|
23
|
|
|
|
|
42
|
|
|
23
|
|
|
|
|
1154
|
|
4
|
23
|
|
|
23
|
|
630
|
use FormValidator::Simple::Exception; |
|
23
|
|
|
|
|
45
|
|
|
23
|
|
|
|
|
181
|
|
5
|
23
|
|
|
23
|
|
1238
|
use FormValidator::Simple::Constants; |
|
23
|
|
|
|
|
44
|
|
|
23
|
|
|
|
|
11854
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
56
|
|
|
56
|
0
|
5374
|
my $class = shift; |
9
|
56
|
|
|
|
|
176
|
my $self = bless { }, $class; |
10
|
56
|
|
|
|
|
202
|
$self->_init(@_); |
11
|
56
|
|
|
|
|
257
|
return $self; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _init { |
15
|
56
|
|
|
56
|
|
110
|
my ($self, $input) = @_; |
16
|
56
|
|
|
|
|
206
|
$self->{_records} = {}; |
17
|
56
|
|
|
|
|
109
|
my $errmsg = qq/Set input data as a hashref or object that has the method 'param()'./; |
18
|
56
|
50
|
|
|
|
270
|
if ( Scalar::Util::blessed($input) ) { |
|
|
0
|
|
|
|
|
|
19
|
56
|
50
|
|
|
|
251
|
unless ( $input->can('param') ) { |
20
|
0
|
|
|
|
|
0
|
FormValidator::Simple::Exception->throw($errmsg); |
21
|
|
|
|
|
|
|
} |
22
|
56
|
|
|
|
|
747
|
foreach my $key ( $input->param ) { |
23
|
187
|
|
|
|
|
1601
|
my @v = $input->param($key); |
24
|
187
|
100
|
|
|
|
3859
|
$self->{_records}{$key} = scalar(@v) > 1 ? \@v : $v[0]; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
elsif ( ref $input eq 'HASH' ) { |
28
|
0
|
|
|
|
|
0
|
$self->{_records} = $input; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
0
|
|
|
|
|
0
|
FormValidator::Simple::Exception->throw($errmsg); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub has_key { |
36
|
0
|
|
|
0
|
0
|
0
|
my ($self, $key) = @_; |
37
|
0
|
0
|
|
|
|
0
|
return exists $self->{_records}{$key} ? TRUE : FALSE; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub param { |
41
|
104
|
|
|
104
|
0
|
2664
|
my ($self, $keys) = @_; |
42
|
155
|
100
|
|
|
|
735
|
my @values = map { |
43
|
104
|
|
|
|
|
197
|
exists $self->{_records}{$_} |
44
|
|
|
|
|
|
|
? $self->{_records}{$_} |
45
|
|
|
|
|
|
|
: '' |
46
|
|
|
|
|
|
|
; |
47
|
|
|
|
|
|
|
} @$keys; |
48
|
104
|
50
|
|
|
|
413
|
return wantarray ? @values : \@values; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
__END__ |