line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::CheckArgs::Object; |
2
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
84
|
use strict; |
|
13
|
|
|
|
|
28
|
|
|
13
|
|
|
|
|
437
|
|
4
|
13
|
|
|
13
|
|
854
|
use warnings; |
|
13
|
|
|
|
|
25
|
|
|
13
|
|
|
|
|
367
|
|
5
|
|
|
|
|
|
|
|
6
|
13
|
|
|
13
|
|
65
|
use Carp qw( croak ); |
|
13
|
|
|
|
|
19
|
|
|
13
|
|
|
|
|
8460
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
60
|
|
|
60
|
0
|
98
|
my $class = shift; |
10
|
60
|
|
|
|
|
92
|
my $config = shift; |
11
|
60
|
|
|
|
|
102
|
my $field = shift; |
12
|
60
|
|
|
|
|
80
|
my $value = shift; |
13
|
|
|
|
|
|
|
|
14
|
60
|
|
|
|
|
381
|
bless { config => $config, field => $field, value => $value }, $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub field { |
18
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
19
|
0
|
|
|
|
|
0
|
return $self->{field}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub value { |
23
|
106
|
|
|
106
|
0
|
203
|
my $self = shift; |
24
|
106
|
100
|
|
|
|
253
|
$self->{value} = shift if @_; |
25
|
106
|
|
|
|
|
401
|
return $self->{value}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub error_code { |
29
|
84
|
|
|
84
|
0
|
126
|
my $self = shift; |
30
|
84
|
100
|
|
|
|
235
|
$self->{error_code} = shift if @_; |
31
|
84
|
|
|
|
|
296
|
return $self->{error_code}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub error_message { |
35
|
56
|
|
|
56
|
0
|
77
|
my $self = shift; |
36
|
56
|
100
|
|
|
|
916
|
$self->{error_message} = shift if @_; |
37
|
56
|
|
|
|
|
179
|
return $self->{error_message}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub config { |
41
|
120
|
|
|
120
|
0
|
694
|
my $self = shift; |
42
|
120
|
|
|
|
|
267
|
return $self->{config}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub check_params { |
46
|
60
|
|
|
60
|
0
|
95
|
my $self = shift; |
47
|
60
|
|
|
|
|
195
|
my %params = @_; |
48
|
|
|
|
|
|
|
|
49
|
60
|
|
|
|
|
252
|
my $config = $self->config; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# check for unknown keys in $config |
52
|
60
|
|
|
|
|
1220
|
foreach my $key ( keys %{ $config } ) { |
|
60
|
|
|
|
|
344
|
|
53
|
207
|
100
|
100
|
|
|
875
|
next if $key eq 'params' or $key eq 'noclean'; # we check these seperately |
54
|
157
|
50
|
|
|
|
242
|
unless ( grep { $key eq $_ } qw( as required label order private ) ) { |
|
785
|
|
|
|
|
2211
|
|
55
|
0
|
|
|
|
|
0
|
croak( __PACKAGE__ . ": $key not a legal config key" ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# check for required params |
60
|
60
|
|
|
|
|
119
|
foreach my $req ( @{ $params{required} } ) { |
|
60
|
|
|
|
|
159
|
|
61
|
7
|
100
|
|
|
|
23
|
unless ( exists $config->{params}{$req} ) { |
62
|
1
|
|
|
|
|
195
|
croak( __PACKAGE__ . ": required parameter $req not given" ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# check for legal params |
67
|
59
|
|
|
|
|
77
|
foreach my $key ( keys %{ $config->{params} } ) { |
|
59
|
|
|
|
|
176
|
|
68
|
33
|
50
|
|
|
|
76
|
unless ( grep { $key eq $_ } @{ $params{required} }, @{ $params{optional} } ) { |
|
72
|
|
|
|
|
283
|
|
|
33
|
|
|
|
|
58
|
|
|
33
|
|
|
|
|
95
|
|
69
|
0
|
|
|
|
|
0
|
croak( __PACKAGE__ . ": $key not a legal parameter" ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# check if cleanable |
74
|
59
|
100
|
|
|
|
233
|
unless ( $params{cleanable} ) { |
75
|
27
|
100
|
|
|
|
434
|
croak( __PACKAGE__ . ' does not support cleaning input' ) if exists $config->{noclean}; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub is_valid { |
80
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# each subclassed module should instantiate its own |
83
|
|
|
|
|
|
|
# is_valid method |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
return 1; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |