blib/lib/Rose/HTML/Form/Field/Submit.pm

filter: Statementstmt 84.1% 53 / 63 Branchbran 54.5% 12 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 78.9% 15 / 19 Podpod 83.3% 10 / 12 totaltotal 77.5% 90 / 116 CC 13 SCAR 13.0
CC
13
Cov
76%
__image_html
7.2
hidden_fields
6.0
html_hidden_fields
6.0
CRAP 3.7
« blib/lib/Rose/HTML/Form/Field/DateTime.pm ↑ Summary blib/lib/Rose/HTML/Form/Field/RadioButtonGroup.pm »
1 package Rose::HTML::Form::Field::Submit;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 ▶use Carp();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use base 'Rose::HTML::Form::Field::Input';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 use Rose::Object::MakeMethods::Generic
10 5 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 'boolean' => 'was_submitted',
12 5 );
13  
14 use Rose::HTML::Object::MakeMethods::Localization
15 5 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 localized_message =>
17 [
18 qw(_value)
19 ],
20 5 );
21  
22 5 __PACKAGE__->add_required_html_attrs(
23 {
24 type => 'submit',
25 name => '',
26 });
27  
28 5 our $VERSION = '0.616';
29  
30 0 ▶sub is_button { 1 }
Subroutine is_button: not called CC=1 SCAR=6.9
Pod undocumented
31 30 ▶sub is_empty { 1 }
Subroutine is_empty: called CC=1 SCAR=0.0
Pod documented
32  
33 0 ▶sub hidden_fields { (wantarray) ? () : [] }
Subroutine hidden_fields: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
34 0 ▶sub html_hidden_fields { (wantarray) ? () : [] }
Subroutine html_hidden_fields: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
35  
36 5 *xhtml_hidden_fields = \&html_hidden_fields;
37  
38 107 ▶sub clear { shift->was_submitted(0) }
Subroutine clear: called CC=1 SCAR=0.0
Pod documented
39 1 ▶sub reset { shift->was_submitted(0) }
Subroutine reset: called CC=1 SCAR=0.0
Pod documented
40  
41 1 ▶sub image_html { shift->__image_html(0, @_) }
Subroutine image_html: called CC=1 SCAR=0.0
Pod documented
42 1 ▶sub image_xhtml { shift->__image_html(1, @_) }
Subroutine image_xhtml: called CC=1 SCAR=0.0
Pod documented
43  
44 sub __image_html
45 2 ▶{
Subroutine __image_html: called CC=7 SCAR=19.8
46 2 my($self, $xhtml, %args) = @_;
47  
48 2 $args{'type'} = 'image';
49  
50 2 my %old;
51  
52 2 ▶ while(my($k, $v) = each(%args))
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %args) 6 2 8
53 {
54 6 ▶ if($self->html_attr_exists($k))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->html_attr_exists($k)) 6 0 6
55 {
56 6 $old{$k} = $self->html_attr($k);
57 }
58  
59 6 $self->html_attr($k => $v);
60 }
61  
62 2 ▶ Carp::croak("Missing src attribute") unless(length $self->html_attr('src'));
Branch: 1 branch
BranchTrueFalseTotal
unless length $self->html_attr("src") 0 2 2
63  
64 2 ▶ my $ret = $xhtml ? $self->xhtml : $self->html;
Branch: 1 branch
BranchTrueFalseTotal
$xhtml ? : 1 1 2
65  
66 # Back out changes
67 2 foreach my $attr (keys %args)
68 {
69 6 ▶ if(exists $old{$attr})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $old{$attr}) { } 6 0 6
70 {
71 6 $self->html_attr($attr => $old{$attr});
72 }
73 else
74 {
75 0 $self->delete_html_attr($attr);
76 }
77 }
78  
79 2 return $ret;
80 }
81  
82 sub value_message_id
83 0 ▶{
Subroutine value_message_id: not called CC=2 SCAR=17.9
Pod undocumented
84 0 my($self) = shift;
85  
86 0 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
87 {
88 0 $self->_value_message_id(@_);
89 0 return $self->html_attr(value => $self->_value);
90 }
91  
92 0 return $self->_value_message_id;
93 }
94  
95 5 *value_id = \&value_message_id;
96  
97 sub value
98 40 ▶{
Subroutine value: called CC=3 SCAR=11.1
Pod documented
99 40 my($self) = shift;
100  
101 40 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 17 23 40
102 {
103 17 my $value = $self->_value(@_);
104 17 return $self->SUPER::value($value);
105 }
106  
107 23 my $value = $self->html_attr('value');
108  
109 23 ▶ unless(defined $value)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value) 0 23 23
110 {
111 0 return $self->html_attr(value => $self->_value);
112 }
113  
114 23 return $value;
115 }
116  
117 sub input_value
118 22 ▶{
Subroutine input_value: called CC=1 SCAR=0.0
Pod documented
119 22 my ($self, $value) = @_;
120 5 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
121 22 $self->was_submitted($value eq $self->value);
122 }
123  
124 sub internal_value
125 27 ▶{
Subroutine internal_value: called CC=2 SCAR=6.9
Pod documented
126 27 my ($self) = shift;
127 27 ▶ return $self->value if($self->was_submitted);
Branch: 1 branch
BranchTrueFalseTotal
if $self->was_submitted 1 26 27
128 26 return undef;
129 }
130  
131 5 1;
132  
133 __END__
« blib/lib/Rose/HTML/Form/Field/DateTime.pm ↑ Summary blib/lib/Rose/HTML/Form/Field/RadioButtonGroup.pm »