Form/Input.pm

filter: Statementstmt 79.3% 69 / 87 Branchbran 62.9% 34 / 54 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 84.2% 16 / 19 Podpod 0.0% 0 / 18 totaltotal 61.9% 119 / 192 CC 33 SCAR 36.5
CC
33
Cov
69%
dump
116.5
selected
6.0
form_name_value
5.0
CRAP 38.6
↑ Summary Form.pm »
1 package HTML::Form::Input;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 11 our $VERSION = '6.13';
6  
7 # ABSTRACT: A generic HTML form input element for use with HTML::Form
8  
9 154 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
10 154 my $class = shift;
11 154 my $self = bless {@_}, $class;
12 154 $self;
13 }
14  
15 116 ▶sub add_to_form {
Subroutine add_to_form: called CC=1 SCAR=0.0
Pod undocumented
16 116 my ( $self, $form ) = @_;
17 116 push( @{ $form->{'inputs'} }, $self );
18 116 $self;
19 }
20  
21 10 ▶sub strict {
Subroutine strict: called CC=2 SCAR=6.9
Pod undocumented
22 10 my $self = shift;
23 10 my $old = $self->{strict};
24 10 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 8 2 10
25 8 $self->{strict} = shift;
26 }
27 10 $old;
28 }
29  
30 50 ▶sub fixup { }
Subroutine fixup: called CC=1 SCAR=0.0
Pod undocumented
31  
32 145 ▶sub type {
Subroutine type: called CC=1 SCAR=0.0
Pod undocumented
33 145 shift->{type};
34 }
35  
36 234 ▶sub name {
Subroutine name: called CC=2 SCAR=6.9
Pod undocumented
37 234 my $self = shift;
38 234 my $old = $self->{name};
39 234 ▶ $self->{name} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 233 234
40 234 $old;
41 }
42  
43 1 ▶sub id {
Subroutine id: called CC=2 SCAR=7.0
Pod undocumented
44 1 my $self = shift;
45 1 my $old = $self->{id};
46 1 ▶ $self->{id} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 1 1
47 1 $old;
48 }
49  
50 1 ▶sub class {
Subroutine class: called CC=2 SCAR=7.0
Pod undocumented
51 1 my $self = shift;
52 1 my $old = $self->{class};
53 1 ▶ $self->{class} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 1 1
54 1 $old;
55 }
56  
57 580 ▶sub selected {
Subroutine selected: called CC=6 SCAR=17.9
Pod undocumented
58 580 my ( $self, $sel ) = @_;
59 580 ▶ return undef unless defined $sel;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sel 0 580 580
60 580 ▶ my $attr
Branch: 3 branches
BranchTrueFalseTotal
$sel =~ s/^\^// ? : 6 574 580
$sel =~ s/^#// ? : 20 554 574
$sel =~ s/^\.// ? : 14 540 554
61 = $sel =~ s/^\^// ? "name"
62 : $sel =~ s/^#// ? "id"
63 : $sel =~ s/^\.// ? "class"
64 : "name";
65 580 ▶ return 0 unless defined $self->{$attr};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{$attr} 5 575 580
66 575 return $self->{$attr} eq $sel;
67 }
68  
69 11 ▶sub value {
Subroutine value: called CC=2 SCAR=6.9
Pod undocumented
70 11 my $self = shift;
71 11 my $old = $self->{value};
72 11 ▶ $self->{value} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 10 11
73 11 $old;
74 }
75  
76 6 ▶sub autocomplete {
Subroutine autocomplete: called CC=2 SCAR=6.9
Pod undocumented
77 6 my $self = shift;
78 6 my $old = $self->{autocomplete};
79 6 ▶ $self->{autocomplete} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 2 4 6
80 6 $old;
81 }
82  
83 0 ▶sub possible_values {
Subroutine possible_values: not called CC=1 SCAR=6.9
Pod undocumented
84 0 return;
85 }
86  
87 0 ▶sub other_possible_values {
Subroutine other_possible_values: not called CC=1 SCAR=6.9
Pod undocumented
88 0 return;
89 }
90  
91 0 ▶sub value_names {
Subroutine value_names: not called CC=1 SCAR=6.9
Pod undocumented
92 0 return;
93 }
94  
95 6 ▶sub readonly {
Subroutine readonly: called CC=2 SCAR=6.9
Pod undocumented
96 6 my $self = shift;
97 6 my $old = $self->{readonly};
98 6 ▶ $self->{readonly} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 5 6
99 6 $old;
100 }
101  
102 60 ▶sub disabled {
Subroutine disabled: called CC=2 SCAR=6.9
Pod undocumented
103 60 my $self = shift;
104 60 my $old = $self->{disabled};
105 60 ▶ $self->{disabled} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 59 60
106 60 $old;
107 }
108  
109 76 ▶sub form_name_value {
Subroutine form_name_value: called CC=5 SCAR=16.1
Pod undocumented
110 76 my $self = shift;
111 76 my $name = $self->{'name'};
112 76 ▶ return unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 8 68 76
113 68 ▶ return if $self->disabled;
Branch: 1 branch
BranchTrueFalseTotal
if $self->disabled 3 65 68
114 65 my $value = $self->value;
115 65 ▶ return unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 5 60 65
116 s/\x0d?\x0a|\x0d/\x0d\x0a/g
117 60 for $name, $value;
118 60 return ( $name => $value );
119 }
120  
121 1 ▶sub dump {
Subroutine dump: called CC=16 SCAR=47.6
Pod undocumented
122 1 my $self = shift;
123 1 my $name = $self->name;
124 1 ▶ $name = "<NONAME>" unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 1 1
125 1 my $value = $self->value;
126 1 ▶ $value = "<UNDEF>" unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 1 1
127 1 my $dump = "$name=$value";
128  
129 1 my $type = $self->type;
130  
131 1 ▶ $type .= " disabled" if $self->disabled;
Branch: 1 branch
BranchTrueFalseTotal
if $self->disabled 0 1 1
132 1 ▶ $type .= " readonly" if $self->readonly;
Branch: 1 branch
BranchTrueFalseTotal
if $self->readonly 0 1 1
133 1 ▶ return sprintf "%-30s %s", $dump, "($type)" unless $self->{menu};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"menu"} 1 0 1
134  
135 0 my @menu;
136 0 my $i = 0;
137 0 for ( @{ $self->{menu} } ) {
138 0 my $opt = $_->{value};
139 0 ▶ $opt = "<UNDEF>" unless defined $opt;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opt 0 0 0
140 $opt .= "/$_->{name}"
141 0 ▶ if defined $_->{name} && length $_->{name} && $_->{name} ne $opt;
Branch: 1 branch
BranchTrueFalseTotal
if defined $_->{"name"} and length $_->{"name"} and $_->{"name"} ne $opt 0 0 0
Condition0%0/6
defined $_->{"name"} and length $_->{"name"} and $_->{"name"} ne $opt
!ll&&!rl&&r
000
defined $_->{"name"} and length $_->{"name"}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $_->{"name"} and length $_->{"name"} and $_->{"name"} ne $opt
defined $_->{"name"} length $_->{"name"} $_->{"name"} ne $opt
Truth table0%0/4
A and B and C
A= defined $_->{"name"}B= length $_->{"name"}C= $_->{"name"} ne $opt
ABCresult
0XX0
10X0
1100
1111
142 0 ▶ substr( $opt, 0, 0 ) = "-" if $_->{disabled};
Branch: 1 branch
BranchTrueFalseTotal
if $_->{"disabled"} 0 0 0
143 0 ▶ if ( exists $self->{current} && $self->{current} == $i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'current'} and $self->{'current'} == $i) { } 0 0 0
Condition0%0/3
exists $self->{"current"} and $self->{"current"} == $i
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"current"} and $self->{"current"} == $i
exists $self->{"current"} $self->{"current"} == $i
Truth table0%0/3
A and B
A= exists $self->{"current"}B= $self->{"current"} == $i
ABresult
0X0
100
111
144 0 ▶ substr( $opt, 0, 0 ) = "!" unless $_->{seen};
Branch: 1 branch
BranchTrueFalseTotal
unless $_->{"seen"} 0 0 0
145 0 substr( $opt, 0, 0 ) = "*";
146 }
147 else {
148 0 ▶ substr( $opt, 0, 0 ) = ":" if $_->{seen};
Branch: 1 branch
BranchTrueFalseTotal
if $_->{"seen"} 0 0 0
149 }
150 0 push( @menu, $opt );
151 0 $i++;
152 }
153  
154 0 return sprintf "%-30s %-10s %s", $dump, "($type)",
155 "[" . join( "|", @menu ) . "]";
156 }
157  
158 11 1;
159  
160 __END__
↑ Summary Form.pm »