blib/lib/Rose/HTML/Form/Field/DateTime/Split/MonthDayYear.pm

filter: Statementstmt 97.9% 47 / 48 Branchbran 83.3% 10 / 12 Conditioncond 88.8% 8 / 9 MC/DCmcdc 80.0% 4 / 5 Subroutinesub 100% 13 / 13 Podpod 100% 7 / 7 totaltotal 94.6% 89 / 94 CC 10 SCAR 10.4
CC
10
Cov
94%
decompose_value
6.0
is_full
3.0
coalesce_value
2.0
CRAP 2.8
« blib/lib/Rose/HTML/Object/WithWrapAroundChildren.pm ↑ Summary blib/lib/Rose/HTML/Form/Field/Time/Split/HourMinuteSecond.pm »
1 package Rose::HTML::Form::Field::DateTime::Split::MonthDayYear;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 ▶use Rose::DateTime::Util();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use Rose::HTML::Object::Messages qw(:date);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 ▶use base 'Rose::HTML::Form::Field::DateTime::Split';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 our $VERSION = '0.606';
12  
13 sub build_field
14 42 ▶{
Subroutine build_field: called CC=1 SCAR=0.0
Pod documented
15 42 my($self) = shift;
16  
17 42 $self->add_fields
18 (
19 month =>
20 {
21 type => 'text',
22 size => 2,
23 maxlength => 2,
24 class => 'month',
25 label_id => FIELD_LABEL_MONTH,
26 error_label_id => FIELD_ERROR_LABEL_MONTH,
27 },
28  
29 day =>
30 {
31 type => 'text',
32 size => 2,
33 maxlength => 2,
34 class => 'day',
35 label_id => FIELD_LABEL_DAY,
36 error_label_id => FIELD_ERROR_LABEL_DAY,
37 },
38  
39 year =>
40 {
41 type => 'text',
42 size => 4,
43 maxlength => 4,
44 class => 'year',
45 label_id => FIELD_LABEL_YEAR,
46 error_label_id => FIELD_ERROR_LABEL_YEAR,
47 },
48 );
49 }
50  
51 sub decompose_value
52 339 ▶{
Subroutine decompose_value: called CC=6 SCAR=17.9
Pod documented
53 339 my($self, $value) = @_;
54  
55 339 ▶ return undef unless(defined $value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 302 37 339
56  
57 37 my $date = $self->SUPER::inflate_value($value);
58  
59 37 ▶ unless($date)
Branch: 1 branch
BranchTrueFalseTotal
unless ($date) 3 34 37
60 {
61 5 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 3 my($month, $day, $year) = split('/', $value);
63  
64 return
65 {
66 3 ▶ month => $month || '',
Condition83%5/6
$month || ''
l!l
30
$day || ''
l!l
12
$year || ''
l!l
12
MC/DC0%0/1
$month || ''
$month
MC/DC100%1/1
$day || ''
$day
MC/DC100%1/1
$year || ''
$year
Truth table50%1/2
A
A= $month
Aresult
11
00
Truth table100%2/2
A
A= $day
Aresult
11
00
Truth table100%2/2
A
A= $year
Aresult
11
00
67 day => $day || '',
68 year => $year || '',
69 }
70 }
71  
72 34 my($month, $day, $year) = Rose::DateTime::Util::format_date($date, '%m', '%d', '%Y');
73  
74 return
75 {
76 34 month => $month,
77 day => $day,
78 year => $year,
79 };
80 }
81  
82 sub is_full
83 590 ▶{
Subroutine is_full: called CC=3 SCAR=11.0
Pod documented
84 590 my($self) = shift;
85  
86 1770 ▶ my $count = grep { defined && length }
Condition100%3/3
defined $_ && length $_
!ll&&!rl&&r
133739394
MC/DC100%2/2
defined $_ && length $_
defined $_ length $_
Truth table100%3/3
A && B
A= defined $_B= length $_
ABresult
0X0
100
111
87 590 map { $self->field($_)->internal_value } qw(month day year);
88  
89 590 ▶ return $count == 3 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$count == 3 ? : 73 517 590
90 }
91  
92 sub coalesce_value
93 25 ▶{
Subroutine coalesce_value: called CC=2 SCAR=7.0
Pod documented
94 25 my($self) = shift;
95 75 ▶ return join('/', map { defined($_) ? $_ : '' }
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 75 0 75
96 25 map { $self->field($_)->internal_value } qw(month day year));
97 }
98  
99 sub deflate_value
100 15 ▶{
Subroutine deflate_value: called CC=2 SCAR=6.9
Pod documented
101 15 my($self, $date) = @_;
102 15 ▶ return $self->input_value_filtered unless($date);
Branch: 1 branch
BranchTrueFalseTotal
unless $date 3 12 15
103 12 return Rose::DateTime::Util::format_date($date, '%m/%d/%Y');
104 }
105  
106 sub html_field
107 12 ▶{
Subroutine html_field: called CC=1 SCAR=0.0
Pod documented
108 12 my($self) = shift;
109  
110 12 return '<span class="date">' .
111 $self->field('month')->html_field . '/' .
112 $self->field('day')->html_field . '/' .
113 $self->field('year')->html_field .
114 '</span>';
115 }
116  
117 sub xhtml_field
118 4 ▶{
Subroutine xhtml_field: called CC=1 SCAR=0.0
Pod documented
119 4 my($self) = shift;
120  
121 4 return '<span class="date">' .
122 $self->field('month')->xhtml_field . '/' .
123 $self->field('day')->xhtml_field . '/' .
124 $self->field('year')->xhtml_field .
125 '</span>';
126 }
127  
128 5 ▶if(__PACKAGE__->localizer->auto_load_messages)
Branch: 1 branch
BranchTrueFalseTotal
if (__PACKAGE__->localizer->auto_load_messages) 0 5 5
129 {
130 0 __PACKAGE__->localizer->load_all_messages;
131 }
132  
133 5 ▶use utf8; # The __DATA__ section contains UTF-8 text
Subroutine BEGIN: called CC=1 SCAR=0.0
134  
135 5 1;
136  
137 __DATA__
« blib/lib/Rose/HTML/Object/WithWrapAroundChildren.pm ↑ Summary blib/lib/Rose/HTML/Form/Field/Time/Split/HourMinuteSecond.pm »