File Coverage

blib/lib/Data/HTML/Form/Input.pm
Criterion Covered Total %
statement 35 35 100.0
branch 4 4 100.0
condition n/a
subroutine 9 9 100.0
pod 0 1 0.0
total 48 49 97.9


line stmt bran cond sub pod time code
1              
2             use strict;
3 3     3   75432 use warnings;
  3         20  
  3         75  
4 3     3   12  
  3         6  
  3         73  
5             use Error::Pure qw(err);
6 3     3   1164 use List::Util qw(none);
  3         20342  
  3         57  
7 3     3   174 use Mo qw(build is);
  3         6  
  3         342  
8 3     3   1237 use Mo::utils qw(check_bool check_number);
  3         1307  
  3         1415  
9 3     3   6248 use Readonly;
  3         3690  
  3         46  
10 3     3   221  
  3         7  
  3         837  
11             Readonly::Array our @TYPES => qw(button checkbox color date datetime-local
12             email file hidden image month number password radio range reset search
13             submit tel text time url week);
14              
15             our $VERSION = 0.04;
16              
17             has checked => (
18             is => 'ro',
19             );
20              
21             has css_class => (
22             is => 'ro',
23             );
24              
25             has disabled => (
26             is => 'ro',
27             );
28              
29             has id => (
30             is => 'ro',
31             );
32              
33             has label => (
34             is => 'ro',
35             );
36              
37             has max => (
38             is => 'ro',
39             );
40              
41             has min => (
42             is => 'ro',
43             );
44              
45             has placeholder => (
46             is => 'ro',
47             );
48              
49             has readonly => (
50             is => 'ro',
51             );
52              
53             has required => (
54             is => 'ro',
55             );
56              
57             has size => (
58             is => 'ro',
59             );
60              
61             has value => (
62             is => 'ro',
63             );
64              
65             has type => (
66             is => 'ro',
67             );
68              
69             my $self = shift;
70              
71 3     3 0 1201 # Check checked.
72             check_bool($self, 'checked');
73              
74 3         12 # Check disabled.
75             check_bool($self, 'disabled');
76              
77 3         46 # Check max.
78             check_number($self, 'max');
79              
80 3         29 # Check min.
81             check_number($self, 'min');
82              
83 3         30 # Check readonly.
84             check_bool($self, 'readonly');
85              
86 3         25 # Check required.
87             check_bool($self, 'required');
88              
89 3         24 # Check size.
90             check_number($self, 'size');
91              
92 3         23 # Check type.
93             if (! defined $self->{'type'}) {
94             $self->{'type'} = 'text';
95 3 100       28 }
96 1         3 if (none { $self->{'type'} eq $_ } @TYPES) {
97             err "Parameter 'type' has bad value.";
98 3 100   60   22 }
  60         291  
99 1         7  
100             return;
101             }
102 2         12  
103             1;
104