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

filter: Statementstmt 94.6% 53 / 56 Branchbran 77.7% 14 / 18 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 86.6% 13 / 15 Podpod 100% 10 / 10 totaltotal 86.2% 94 / 109 CC 12 SCAR 11.4
CC
12
Cov
88%
validate
6.7
__ANON__
3.7
input_value
3.0
CRAP 3.1
« blib/lib/Rose/HTML/Form/Field/Hidden.pm ↑ Summary blib/lib/Rose/HTML/Object/Messages.pm »
1 package Rose::HTML::Form::Field::TextArea;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use Carp();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Rose::HTML::Object::Errors qw(:string);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use base 'Rose::HTML::Form::Field';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 our $VERSION = '0.625';
12  
13 3 __PACKAGE__->add_valid_html_attrs
14 (
15 'rows', # NUMBER #REQUIRED
16 'cols', # NUMBER #REQUIRED
17 'disabled', # (disabled) #IMPLIED -- unavailable in this context --
18 'readonly', # (readonly) #IMPLIED
19 'onselect', # %Script; #IMPLIED -- some text was selected --
20 'onchange', # %Script; #IMPLIED -- the element value was changed --
21 'minlength',
22 'maxlength',
23 );
24  
25 3 __PACKAGE__->add_required_html_attrs(
26 {
27 rows => 6,
28 cols => 50,
29 });
30  
31 3 __PACKAGE__->add_boolean_html_attrs
32 (
33 'disabled',
34 'readonly',
35 );
36  
37 0 ▶sub element { 'textarea' }
Subroutine element: not called CC=1 SCAR=6.9
Pod documented
38 28 ▶sub html_element { 'textarea' }
Subroutine html_element: called CC=1 SCAR=0.0
Pod documented
39 14 ▶sub xhtml_element { 'textarea' }
Subroutine xhtml_element: called CC=1 SCAR=0.0
Pod documented
40  
41 1 ▶sub value { shift->input_value(@_) }
Subroutine value: called CC=1 SCAR=0.0
Pod documented
42  
43 sub contents
44 1 ▶{
Subroutine contents: called CC=2 SCAR=8.1
Pod documented
45 1 my($self) = shift;
46 1 ▶ return $self->input_value(@_) if(@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 0 1
47 0 return $self->output_value;
48 }
49  
50 sub input_value
51 48 ▶{
Subroutine input_value: called CC=3 SCAR=11.0
Pod documented
52 48 my($self) = shift;
53  
54 48 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 17 31 48
55 {
56 17 $self->SUPER::input_value(@_);
57 17 ▶ $self->children(defined $_[0] ? $self->output_value : '');
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 12 5 17
58 }
59  
60 # XXX: Intentional double set in order to maintain error()
61 # XXX: produced by a possible call to inflate_value()
62 48 return $self->SUPER::input_value(@_);
63 }
64  
65 sub clear
66 2 ▶{
Subroutine clear: called CC=1 SCAR=0.0
Pod documented
67 2 my($self) = shift;
68 2 $self->delete_children;
69 2 return $self->SUPER::clear(@_);
70 }
71  
72 sub reset
73 2 ▶{
Subroutine reset: called CC=1 SCAR=0.0
Pod documented
74 2 my($self) = shift;
75 2 $self->SUPER::reset(@_);
76 2 $self->children($self->output_value);
77 }
78  
79 sub size
80 4 ▶{
Subroutine size: called CC=3 SCAR=11.0
Pod documented
81 4 my($self) = shift;
82  
83 4 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 2 4
84 {
85 2 local $_ = shift;
86  
87 2 ▶ if(my($cols, $rows) = /^(\d+)x(\d+)$/)
Branch: 1 branch
BranchTrueFalseTotal
if (() = /^(\d+)x(\d+)$/) { } 1 1 2
88 {
89 1 $self->cols($cols);
90 1 $self->rows($rows);
91 1 return $cols . 'x' . $rows;
92 }
93 else
94 {
95 1 Carp::croak "Invalid size argument '$_' is not in the form COLSxROWS";
96 }
97 }
98  
99 2 return $self->cols . 'x' . $self->rows;
100 }
101  
102 sub validate
103 4 ▶{
Subroutine validate: called CC=6 SCAR=19.0
Pod documented
104 4 my($self) = shift;
105  
106 4 my $ok = $self->SUPER::validate(@_);
107 4 ▶ return $ok unless($ok);
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 2 2 4
108  
109 2 my $value = $self->input_value;
110 2 ▶ return 1 unless(defined $value && length $value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and length $value 0 2 2
Condition33%1/3
defined $value and length $value
!ll&&!rl&&r
002
MC/DC0%0/2
defined $value and length $value
defined $value length $value
Truth table33%1/3
A and B
A= defined $valueB= length $value
ABresult
0X0
100
111
111  
112 2 my $maxlength = $self->maxlength;
113  
114 0 ▶ my $name = sub { $self->label || $self->name };
Subroutine __ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
BranchTrueFalseTotal
$self->label or $self->name 0 0 0
115  
116 2 ▶ if(defined $maxlength && length($value) > $maxlength)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $maxlength and length $value > $maxlength) 1 1 2
Condition66%2/3
defined $maxlength and length $value > $maxlength
!ll&&!rl&&r
101
MC/DC50%1/2
defined $maxlength and length $value > $maxlength
defined $maxlength length $value > $maxlength
Truth table66%2/3
A and B
A= defined $maxlengthB= length $value > $maxlength
ABresult
0X0
100
111
117 {
118 1 $self->add_error_id(STRING_OVERFLOW, { label => $name, maxlength => $maxlength });
119 1 return 0;
120 }
121  
122 1 return 1;
123 }
124 3 1;
125  
126 __END__
« blib/lib/Rose/HTML/Form/Field/Hidden.pm ↑ Summary blib/lib/Rose/HTML/Object/Messages.pm »