Instrumented/Form/ElementControl.pm

filter: Statementstmt 28.2% 13 / 46 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 40.0% 4 / 10 Podpod 100% 6 / 6 totaltotal 23.4% 23 / 98 CC 16 SCAR 31.3
CC
16
Cov
17%
set_value
42.0
value
30.0
if
20.0
CRAP 22.8
« Instrumented/Loop.pm ↑ Summary Instrumented/Form/Hidden.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
5 XHTML::Instrumented::Form::ElementControl;
6  
7 2 ▶use base 'XHTML::Instrumented::Control';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub if
12 0 ▶{
Subroutine if: not called CC=4 SCAR=30.0
Pod documented
13 0 my $self = shift;
14  
15 0 my $x = 0;
16  
17 0 ▶ $x++ if defined $self->{value};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"value"} 0 0 0
18 0 ▶ $x++ if defined $self->{default};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"default"} 0 0 0
19 0 ▶ $x++ if defined $self->{required};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"required"} 0 0 0
20  
21 0 $x;
22 }
23  
24 sub set_value
25 0 ▶{
Subroutine set_value: not called CC=6 SCAR=37.4
Pod documented
26 0 my $self = shift;
27 0 my $value = shift;
28 0 ▶ die if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
29  
30 0 ▶ if (my $type = ref($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $type = ref $value) { } 0 0 0
31 0 ▶ die unless $type eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "ARRAY" 0 0 0
32 0 ▶ if (@{$value} == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (@{$value;} == 1) { } 0 0 0
elsif (@{$value;} == 0) { } 0 0 0
33 0 $self->{value} = $value->[0];
34 0 } elsif (@{$value} == 0) {
35 0 $self->{value} = '';
36 } else {
37 0 die 'bad data ' . "@{$value}";
38 }
39 } else {
40 0 $self->{value} = $value;
41 }
42 }
43  
44 sub set_label
45 0 ▶{
Subroutine set_label: not called CC=1 SCAR=6.9
Pod documented
46 0 my $self = shift;
47  
48 0 $self->{label} = shift;
49 }
50  
51 sub is_multi
52 0 ▶{
Subroutine is_multi: not called CC=1 SCAR=6.9
Pod documented
53 0 0;
54 }
55  
56 sub value
57 0 ▶{
Subroutine value: not called CC=5 SCAR=34.0
Pod documented
58 0 my $self = shift;
59  
60 0 ▶ if ($self->is_multi) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_multi) { } 0 0 0
61 0 die $self;
62 0 ▶ $self->{value} || $self->{default} || [];
Branch: 1 branch
BranchTrueFalseTotal
$self->{"value"} or $self->{"default"} or [] 0 0 0
Condition0%0/3
$self->{"value"} or $self->{"default"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"value"} or $self->{"default"}
$self->{"value"} $self->{"default"}
Truth table0%0/3
A or B
A= $self->{"value"}B= $self->{"default"}
ABresult
1X1
011
000
63 } else {
64 0 ▶ $self->{value} || $self->{default};
Branch: 1 branch
BranchTrueFalseTotal
$self->{"value"} or $self->{"default"} 0 0 0
65 }
66 }
67  
68 sub required
69 0 ▶{
Subroutine required: not called CC=4 SCAR=30.0
Pod documented
70 0 my $self = shift;
71  
72 0 ▶ if (exists $self->{required} and $self->{required}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'required'} and $self->{'required'}) { } 0 0 0
Condition0%0/3
exists $self->{"required"} and $self->{"required"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"required"} and $self->{"required"}
exists $self->{"required"} $self->{"required"}
Truth table0%0/3
A and B
A= exists $self->{"required"}B= $self->{"required"}
ABresult
0X0
100
111
73 0 ▶ if (exists $self->{value}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'value'}) { } 0 0 0
74 0 !length($self->{value});
75 } else {
76 0 0;
77 }
78 } else {
79 0 0;
80 }
81 }
82  
83 2 1;
84 __END__
« Instrumented/Loop.pm ↑ Summary Instrumented/Form/Hidden.pm »