Instrumented/Form/Control.pm

filter: Statementstmt 33.3% 13 / 39 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 44.4% 4 / 9 Podpod 100% 5 / 5 totaltotal 27.1% 22 / 81 CC 13 SCAR 32.8
CC
13
Cov
21%
expand_content
56.0
args
20.0
get_element
20.0
CRAP 26.7
« Instrumented/Form.pm ↑ Summary Instrumented/Control.pm »
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::Control;
5  
6 2 ▶use base 'XHTML::Instrumented::Control';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub args
11 0 ▶{
Subroutine args: not called CC=4 SCAR=30.0
Pod documented
12 0 my $self = shift;
13  
14 0 my %hash;
15 0 ▶ $hash{action} = $self->{self}{action} if $self->{self}{action};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"self"}{"action"} 0 0 0
16 0 ▶ $hash{method} = $self->{self}{method} if $self->{self}{method};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"self"}{"method"} 0 0 0
17 0 ▶ if (my $name = $self->{self}{name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $name = $self->{"self"}{"name"}) 0 0 0
18 0 $hash{name} = $name;
19 }
20  
21 0 ('method', 'post', @_, %hash );
22 }
23  
24 sub expand_content
25 0 ▶{
Subroutine expand_content: not called CC=7 SCAR=40.3
Pod documented
26 0 my $self = shift;
27  
28 0 my @ret = @_;
29  
30 0 for my $hidden ($self->{self}->auto()) {
31 0 ▶ die 'need value for ' . $hidden->name if !$hidden->value && $hidden->required;
Branch: 1 branch
BranchTrueFalseTotal
if not $hidden->value and $hidden->required 0 0 0
Condition0%0/3
not $hidden->value and $hidden->required
!ll&&!rl&&r
000
MC/DC0%0/2
not $hidden->value and $hidden->required
not $hidden->value $hidden->required
Truth table0%0/3
not(A) and B
A= not $hidden->valueB= $hidden->required
ABresult
0X0
100
111
32 0 ▶ warn 'need value for ' . $hidden->name unless $hidden->value || $hidden->optional;
Branch: 1 branch
BranchTrueFalseTotal
unless $hidden->value or $hidden->optional 0 0 0
Condition0%0/3
$hidden->value or $hidden->optional
l!l&&r!l&&!r
000
MC/DC0%0/2
$hidden->value or $hidden->optional
$hidden->value $hidden->optional
Truth table0%0/3
A or B
A= $hidden->valueB= $hidden->optional
ABresult
1X1
011
000
33 0 ▶ next unless $hidden->value;
Branch: 1 branch
BranchTrueFalseTotal
unless $hidden->value 0 0 0
34 0 unshift(@ret, sprintf(qq(<input name="%s" type="hidden" value="%s"/>), $hidden->name, $hidden->value));
35 }
36 0 $self->SUPER::expand_content(@ret);
37 }
38  
39 sub is_form
40 0 ▶{
Subroutine is_form: not called CC=1 SCAR=6.9
Pod documented
41 0 1;
42 }
43  
44 sub form
45 0 ▶{
Subroutine form: not called CC=1 SCAR=6.9
Pod documented
46 0 shift->{self};
47 }
48  
49 sub get_element
50 0 ▶{
Subroutine get_element: not called CC=4 SCAR=30.0
Pod documented
51 0 my $self = shift;
52 0 ▶ my $name = shift or croak('need a name');
Branch: 1 branch
BranchTrueFalseTotal
my $name = shift() or croak("need a name") 0 0 0
53 0 my $form = $self->{self};
54  
55 0 my $ret = $form->{elements}{$name};
56  
57 0 ▶ if ($ret) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ret) 0 0 0
58 0 ▶ if ($ret->is_multi) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ret->is_multi) { } 0 0 0
59 0 $ret->{default} = [ $form->element_values($name) ];
60 } else {
61 0 $ret->{default} = $form->element_value($name);
62 }
63 }
64  
65 0 return $ret;
66 }
67  
68 2 1;
69 __END__
« Instrumented/Form.pm ↑ Summary Instrumented/Control.pm »