| 1 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | package XHTML::Instrumented::Form; | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = '0.09'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use XHTML::Instrumented::Form::Control; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use XHTML::Instrumented::Form::Select; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Params::Validate qw( validate SCALAR BOOLEAN HASHREF OBJECT ARRAYREF ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Carp qw (croak carp); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | XHTML::Instramented::Form - XHTML::Instramented Form Object | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | my $template = XHTML::Instrumented->new(name => 'bob'); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | my $form = $template->get_form(name => 'myform'); | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | =head1 API | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | =head2 Constructor | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | =item new | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my %p = validate( | |||||||||||||||||||||||||||||||||||||||||
| 42 | @_, { | ||||||||||||||||||||||||||||||||||||||||||
| 43 | action => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 44 | id => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | required => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | name => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | method => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | bless { %p }, $class; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | sub add_params | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_params: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $self->{params} = { @_ }; | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | for my $name (keys %{$self->{params}}) { | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $element = $self->get_element($name); | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | next unless $element; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $element->set_value($self->{params}{$name}); | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | sub add_defaults | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_defaults: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $self->{defaults} = { @_ }; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | for my $name (keys %{$self->{defaults}}) { | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my $element = $self->get_element($name); | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if ($element) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $element->set_default($self->{defaults}{$name}); | |||||||||||||||||||||||||||||||||||||||||
| 78 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | warn 'add defaults ' . $name; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | sub element_values | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_values: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | my $key = shift or die; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | @ret = @{ $self->{defaults}{$key} || [] }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'defaults'}{$key} || []
MC/DC0%0/1
$self->{'defaults'}{$key} || []
$self->{'defaults'}{$key}
Truth table0%0/2
A
A= $self->{'defaults'}{$key}
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if ($self->{params}{$key}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | @ret = @{$self->{params}{$key} || []}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'params'}{$key} || []
MC/DC0%0/1
$self->{'params'}{$key} || []
$self->{'params'}{$key}
Truth table0%0/2
A
A= $self->{'params'}{$key}
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | @ret; | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | sub element_value | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_value: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | my $key = shift or die; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | @ret = ($self->{defaults}{$key}); | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ($self->{params}{$key}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | @ret = @{$self->{params}{$key} || []}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'params'}{$key} || []
MC/DC0%0/1
$self->{'params'}{$key} || []
$self->{'params'}{$key}
Truth table0%0/2
A
A= $self->{'params'}{$key}
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $ret[0]; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | sub _control | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_control: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | bless { self => $self, }, 'XHTML::Instrumented::Form::Control'; | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | sub set_select_data | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_select_data: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my %p = validate(@_, { | |||||||||||||||||||||||||||||||||||||||||
| 125 | name => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 126 | data => ARRAYREF, | ||||||||||||||||||||||||||||||||||||||||||
| 127 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $select = $self->get_element($p{name}); | |||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | croak('No select element found: ' . $p{name}) unless $select; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $select->set_select_data(@{$p{data}}); | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | sub delete_element | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_element: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my %p = validate(@_, | |||||||||||||||||||||||||||||||||||||||||
| 140 | { | ||||||||||||||||||||||||||||||||||||||||||
| 141 | name => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | my $name = $p{name} or die 'No name for element'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $ret = $self->{elements}->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | delete $self->{elements}->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | sub add_element | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_element: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my %p = validate(@_, | |||||||||||||||||||||||||||||||||||||||||
| 155 | { | ||||||||||||||||||||||||||||||||||||||||||
| 156 | name => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 157 | type => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 158 | required => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 159 | optional => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 160 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 161 | value => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 162 | data => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 163 | values => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 164 | multiple => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 165 | remove => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 166 | onclick => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 167 | onchange => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 168 | class => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 169 | package => { | ||||||||||||||||||||||||||||||||||||||||||
| 170 | optional => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 171 | isa => 'XHTML::Instrumented::Form::ElementControl', | ||||||||||||||||||||||||||||||||||||||||||
| 172 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | my $name = $p{name} or die 'No name for element'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if ($self->{elements}->{$name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | die "element $name already defined"; | |||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | $p{type} ||= 'text'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$p{"type"} ||= "text"
MC/DC0%0/1
$p{"type"} ||= "text"
$p{"type"}
Truth table0%0/2
A
A= $p{"type"}
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if (my $package = $p{package}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | delete $p{package}; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $self->{elements}->{$name} = $package->new(%p); | |||||||||||||||||||||||||||||||||||||||||
| 186 | ▶ | } elsif ($p{type} eq 'multiselect' or $p{type} eq 'checkbox') { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$p{"type"} eq "multiselect" or $p{"type"} eq "checkbox"
MC/DC0%0/2
$p{"type"} eq "multiselect" or $p{"type"} eq "checkbox"
$p{"type"} eq "multiselect"
$p{"type"} eq "checkbox"
Truth table0%0/3
A or B
A= $p{"type"} eq "multiselect"B= $p{"type"} eq "checkbox"
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | require XHTML::Instrumented::Form::Checkbox; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $self->{elements}->{$name} = XHTML::Instrumented::Form::Checkbox->new(%p); | |||||||||||||||||||||||||||||||||||||||||
| 189 | } elsif ($p{type} eq 'select') { | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | require XHTML::Instrumented::Form::Select; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $self->{elements}->{$name} = XHTML::Instrumented::Form::Select->new(%p); | |||||||||||||||||||||||||||||||||||||||||
| 192 | } elsif ($p{type} eq 'hidden') { | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | require XHTML::Instrumented::Form::Hidden; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $self->{elements}->{$name} = XHTML::Instrumented::Form::Hidden->new(%p); | |||||||||||||||||||||||||||||||||||||||||
| 195 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | require XHTML::Instrumented::Form::Element; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $self->{elements}->{$name} = XHTML::Instrumented::Form::Element->new(%p); | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $self->{elements}->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | sub set_element | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_element: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my $args = { @_ }; | |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | my $name = $args->{name} or die 'No name for element'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my $element = $self->{elements}->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | for my $key (keys %$args) { | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $element->{$key} = $args->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | return $element; | |||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | sub args | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
args: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | %{$self->{elements} || {}}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'elements'} || {}
MC/DC0%0/1
$self->{'elements'} || {}
$self->{'elements'}
Truth table0%0/2
A
A= $self->{'elements'}
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | sub params | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
params: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my $hash = {}; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | die; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | $hash->{action} = $self->{action} if $self->{action}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | $hash->{method} = $self->{method} if $self->{method}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $hash; | |||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | sub context | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
context: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | action => 'bob', | |||||||||||||||||||||||||||||||||||||||||
| 241 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | sub is_select | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_select: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | my $id = shift || die 'no id.'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || die('no id.')
MC/DC0%0/1
shift() || die('no id.')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my $ret = 0; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if (my $element = $self->{elements}{$id}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | if ($element->{type} eq 'select') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | for my $data (@{$element->{data}}) { | |||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if (defined($data->{value}) && defined($self->element_value($id)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $data->{"value"} and defined $self->element_value($id) and $self->element_value($id) eq $data->{"value"}
defined $data->{"value"} and defined $self->element_value($id)
MC/DC0%0/3
defined $data->{"value"} and defined $self->element_value($id) and $self->element_value($id) eq $data->{"value"}
defined $data->{"value"}
defined $self->element_value($id)
$self->element_value($id) eq $data->{"value"}
Truth table0%0/4
A and B and C
A= defined $data->{"value"}B= defined $self->element_value($id)C= $self->element_value($id) eq $data->{"value"}
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | && $self->element_value($id) eq $data->{value}) { | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $data->{selected} = 'selected'; | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | [ @{$element->{data}} ]; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | []; | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | sub get_element | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_element: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my $ret = $self->{elements}{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if ($ret) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $ret->{_default} = $self->element_value($name); | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | $ret->{default} ||= $self->element_value($name); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ret->{"default"} ||= $self->element_value($name)
MC/DC0%0/2
$ret->{"default"} ||= $self->element_value($name)
$ret->{"default"}
$self->element_value($name)
Truth table0%0/3
A ||= B
A= $ret->{"default"}B= $self->element_value($name)
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | sub is_element | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_element: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my $args = { @_ }; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my $ret = 0; | |||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | if (my $name = $args->{name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if ($self->{elements}{$name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $ret = 1; | |||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $ret; | |||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | sub auto | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | for my $element (keys %{$self->{elements}}) { | |||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | next unless $self->{elements}{$element}{type} eq 'hidden'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my $x = $self->get_element($element); | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | if (ref($x->{value}) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | push(@ret, map({bless({ type => 'hidden', name => $x->{name}, value => $_ }, ref($x) );} @{$x->{value}} )); | |||||||||||||||||||||||||||||||||||||||||
| 304 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | unless (defined $x->{value}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $x->{value} = $self->element_value($element); | |||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | push(@ret, $x); | |||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | @ret; | |||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | sub update_argumants | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_argumants: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | my $args = { @_ }; | |||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $args->{args}; | |||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | sub name | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $self->{name}; | |||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 332 | __END__ | ||||||||||||||||||||||||||||||||||||||||||