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

filter: Statementstmt 95.2% 40 / 42 Branchbran 71.4% 10 / 14 Conditioncond 88.8% 8 / 9 MC/DCmcdc 83.3% 5 / 6 Subroutinesub 88.8% 8 / 9 Podpod 100% 3 / 3 totaltotal 89.1% 74 / 83 CC 10 SCAR 16.9
CC
10
Cov
89%
validate
9.2
__ANON__
3.7
BEGIN
1.0
CRAP 5.4
« blib/lib/Rose/HTML/Form/Field/Set.pm ↑ Summary blib/lib/Rose/HTML/Object.pm »
1 package Rose::HTML::Form::Field::Text;
2  
3 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 17 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 17 ▶use Rose::HTML::Object::Errors qw(:string);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 17 ▶use base 'Rose::HTML::Form::Field::Input';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 17 our $VERSION = '0.606';
11  
12 17 __PACKAGE__->delete_valid_html_attrs(qw(ismap usemap alt src));
13  
14 17 __PACKAGE__->add_required_html_attrs(
15 {
16 type => 'text',
17 name => '',
18 size => 15,
19 value => '',
20 });
21  
22 sub html_field
23 145 ▶{
Subroutine html_field: called CC=1 SCAR=0.0
Pod documented
24 145 my($self) = shift;
25 145 $self->html_attr(value => $self->output_value);
26 145 return $self->SUPER::html_field(@_);
27 }
28  
29 sub xhtml_field
30 98 ▶{
Subroutine xhtml_field: called CC=1 SCAR=0.0
Pod documented
31 98 my($self) = shift;
32 98 $self->html_attr(value => $self->output_value);
33 98 return $self->SUPER::xhtml_field(@_);
34 }
35  
36 sub validate
37 134 ▶{
Subroutine validate: called CC=9 SCAR=22.2
Pod documented
38 134 my($self) = shift;
39  
40 134 my $ok = $self->SUPER::validate(@_);
41 134 ▶ return $ok unless($ok);
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 11 123 134
42  
43 123 my $value = $self->input_value;
44 123 ▶ $value = $self->output_value if(ref $value);
Branch: 1 branch
BranchTrueFalseTotal
if ref $value 0 123 123
45 123 ▶ return 1 unless(defined $value && length $value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and length $value 26 97 123
Condition100%3/3
defined $value and length $value
!ll&&!rl&&r
24297
MC/DC100%2/2
defined $value and length $value
defined $value length $value
Truth table100%3/3
A and B
A= defined $valueB= length $value
ABresult
0X0
100
111
46  
47 97 my $maxlength = $self->maxlength;
48  
49 0 ▶ my $name = sub { $self->error_label || $self->name };
Subroutine __ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
BranchTrueFalseTotal
$self->error_label or $self->name 0 0 0
50  
51 97 ▶ if(ref($self)->force_utf8 && !Encode::is_utf8($value))
Branch: 1 branch
BranchTrueFalseTotal
if (ref($self)->force_utf8 and not &Encode::is_utf8($value)) 1 96 97
Condition66%2/3
ref($self)->force_utf8 and not &Encode::is_utf8($value)
!ll&&!rl&&r
9601
MC/DC50%1/2
ref($self)->force_utf8 and not &Encode::is_utf8($value)
ref($self)->force_utf8 not &Encode::is_utf8($value)
Truth table66%2/3
A and not(B)
A= ref($self)->force_utf8B= not &Encode::is_utf8($value)
ABresult
0X0
100
111
52 {
53 1 Encode::_utf8_on($value);
54 }
55  
56 97 ▶ if(defined $maxlength && length($value) > $maxlength)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $maxlength and length $value > $maxlength) 3 94 97
Condition100%3/3
defined $maxlength and length $value > $maxlength
!ll&&!rl&&r
48463
MC/DC100%2/2
defined $maxlength and length $value > $maxlength
defined $maxlength length $value > $maxlength
Truth table100%3/3
A and B
A= defined $maxlengthB= length $value > $maxlength
ABresult
0X0
100
111
57 {
58 3 $self->add_error_id(STRING_OVERFLOW, { label => $name, maxlength => $maxlength });
59 3 return 0;
60 }
61  
62 94 return 1;
63 }
64  
65 17 ▶if(__PACKAGE__->localizer->auto_load_messages)
Branch: 1 branch
BranchTrueFalseTotal
if (__PACKAGE__->localizer->auto_load_messages) 0 17 17
66 {
67 0 __PACKAGE__->localizer->load_all_messages;
68 }
69  
70 17 ▶use utf8; # The __DATA__ section contains UTF-8 text
Subroutine BEGIN: called CC=1 SCAR=0.0
71  
72 17 1;
73  
74 __DATA__
« blib/lib/Rose/HTML/Form/Field/Set.pm ↑ Summary blib/lib/Rose/HTML/Object.pm »