blib/lib/Rose/HTML/Form/Field/OnOff/Checkable.pm

filter: Statementstmt 97.2% 35 / 36 Branchbran 95.0% 19 / 20 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod 42.8% 3 / 7 totaltotal 87.0% 67 / 77 CC 12 SCAR 15.3
CC
12
Cov
93%
checked
8.3
hidden
4.0
is_checked
2.0
CRAP 4.6
« blib/lib/Rose/HTML/Objects.pm ↑ Summary blib/lib/Rose/HTML/Form/Field/Compound.pm »
1 package Rose::HTML::Form::Field::OnOff::Checkable;
2  
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 9 ▶use base 'Rose::HTML::Form::Field::OnOff';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 9 our $VERSION = '0.606';
8  
9 9 __PACKAGE__->add_required_html_attrs(
10 {
11 value => 'on',
12 });
13  
14 sub checked
15 1204 ▶{
Subroutine checked: called CC=8 SCAR=21.2
Pod undocumented
16 1204 my($self) = shift;
17  
18 1204 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 555 649 1204
19 {
20 555 $self->is_cleared(0);
21  
22 555 ▶ $self->{'checked'} =
Branch: 2 branches
BranchTrueFalseTotal
$_[0] ? : 42 513 555
defined $_[0] ? : 455 58 513
23 $self->html_attr(checked => $_[0] ? 1 : (defined $_[0] ? 0 : undef));
24  
25 555 ▶ if((my $parent = $self->parent_field) && $self->auto_invalidate_parent)
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = $self->parent_field and $self->auto_invalidate_parent) 0 555 555
Condition33%1/3
my $parent = $self->parent_field and $self->auto_invalidate_parent
!ll&&!rl&&r
55500
MC/DC0%0/2
my $parent = $self->parent_field and $self->auto_invalidate_parent
my $parent = $self->parent_field $self->auto_invalidate_parent
Truth table33%1/3
A and B
A= my $parent = $self->parent_fieldB= $self->auto_invalidate_parent
ABresult
0X0
100
111
26 {
27 0 $parent->invalidate_value;
28 }
29  
30 555 return $self->{'checked'};
31 }
32  
33 649 ▶ return 0 if($self->is_cleared);
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_cleared 93 556 649
34 556 ▶ return defined $self->{'checked'} ? $self->{'checked'} : $self->default_value;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'checked'} ? : 304 252 556
35 }
36  
37 9 *input_value = \&checked;
38  
39 259 ▶sub is_checked { shift->checked ? 1 : 0 }
Subroutine is_checked: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
(shift())->checked ? : 100 159 259
40  
41 259 ▶sub is_on { shift->is_checked }
Subroutine is_on: called CC=1 SCAR=0.0
Pod undocumented
42  
43 143 ▶sub value { shift->html_attr('value', @_) }
Subroutine value: called CC=1 SCAR=0.0
Pod documented
44  
45 sub clear
46 380 ▶{
Subroutine clear: called CC=1 SCAR=0.0
Pod documented
47 380 my($self) = shift;
48  
49 380 $self->checked(0);
50 380 $self->error(undef);
51 380 $self->is_cleared(1);
52 }
53  
54 sub reset
55 42 ▶{
Subroutine reset: called CC=1 SCAR=0.0
Pod documented
56 42 my($self) = shift;
57  
58 42 $self->checked(undef);
59 42 $self->error(undef);
60 42 $self->is_cleared(0);
61 42 return 1;
62 }
63  
64 sub hidden
65 387 ▶{
Subroutine hidden: called CC=4 SCAR=13.9
Pod undocumented
66 387 my($self) = shift;
67  
68 387 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 32 355 387
69 {
70 32 ▶ if($self->{'_hidden'} = shift(@_) ? 1 : 0)
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{"_hidden"} = shift @_ ? 1 : 0) 16 16 32
shift @_ ? : 16 16 32
71 {
72 16 $self->checked(undef);
73 }
74 }
75  
76 387 return $self->{'_hidden'};
77 }
78  
79 9 1;
« blib/lib/Rose/HTML/Objects.pm ↑ Summary blib/lib/Rose/HTML/Form/Field/Compound.pm »