| 1 | package Rose::HTML::Form::Field::DateTime::Range; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Rose::HTML::Object::Errors qw(:date); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | use Rose::HTML::Object::Messages | ||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | qw(FIELD_ERROR_LABEL_MINIMUM_DATE FIELD_ERROR_LABEL_MAXIMUM_DATE); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Rose::HTML::Form::Field::DateTime::StartDate; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Rose::HTML::Form::Field::DateTime::EndDate; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use base 'Rose::HTML::Form::Field::Compound'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | use Rose::Object::MakeMethods::Generic | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | 'scalar --get_set_init' => | |||||||||||||||||||||||||||||||||||||||||
| 18 | [ | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 'range_separator_regex', | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 'min_prefix_html', | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 'max_prefix_html', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 'separator_html', | ||||||||||||||||||||||||||||||||||||||||||
| 23 | ] | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | our $VERSION = '0.606'; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | sub build_field | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_field: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | $self->add_fields | |||||||||||||||||||||||||||||||||||||||||
| 33 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 34 | min => | ||||||||||||||||||||||||||||||||||||||||||
| 35 | { | ||||||||||||||||||||||||||||||||||||||||||
| 36 | type => 'datetime start', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | error_label_id => FIELD_ERROR_LABEL_MINIMUM_DATE, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | size => 21, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | maxlength => 25, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | max => | ||||||||||||||||||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||||||||||||||||
| 44 | type => 'datetime end', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | error_label_id => FIELD_ERROR_LABEL_MAXIMUM_DATE, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | size => 21, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | maxlength => 25, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | sub size | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
size: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if(@_) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | { | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $self->field('min')->size(@_); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $self->field('max')->size(@_); | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | return $self->field('min')->size(@_); | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | sub output_format | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output_format: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if(@_) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $self->field('min')->output_format(@_); | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $self->field('max')->output_format(@_); | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return $self->field('min')->output_format(@_); | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | sub init_range_separator { '#' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_range_separator: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | sub init_range_separator_regex { qr(#|\s+to\s+) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_range_separator_regex: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | sub range_separator | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
range_separator: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 6 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 6 | ▶ | if(@_) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | $self->invalidate_output_value; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | return $self->{'range_separator'} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | return (defined $self->{'range_separator'}) ? $self->{'range_separator'} : | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 5 | ▶ | ($self->{'range_separator'} = $self->init_range_separator); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | sub deflate_value | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deflate_value: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 3 | my($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | ▶ | return $value unless(ref $value && @$value == 2); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $value and @$value == 2
MC/DC0%0/2
ref $value and @$value == 2
ref $value
@$value == 2
Truth table33%1/3
A and B
A= ref $valueB= @$value == 2
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | return join($self->range_separator, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 3 | map { $_->strftime('%Y-%m-%d %H:%M:%S') } @$value); | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | sub coalesce_value | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coalesce_value: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 4 | ▶ | return join($self->range_separator, map { defined($_) ? $_ : '' } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | map { $self->field($_)->output_value } | |||||||||||||||||||||||||||||||||||||||||
| 108 | qw(min max)); | ||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | sub decompose_value | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decompose_value: called CC=7 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 17 | my($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 17 | ▶ | return undef unless(defined $value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 12 | my($min, $max); | |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 12 | ▶ | if(ref $value eq 'ARRAY' && @$value == 2) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
ref $value eq "ARRAY" and @$value == 2
MC/DC50%1/2
ref $value eq "ARRAY" and @$value == 2
ref $value eq "ARRAY"
@$value == 2
Truth table66%2/3
A and B
A= ref $value eq "ARRAY"B= @$value == 2
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 2 | ($min, $max) = @$value; | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | elsif(!ref $value) | ||||||||||||||||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 10 | ($min, $max) = split($self->range_separator_regex, $value, 2); | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | else | ||||||||||||||||||||||||||||||||||||||||||
| 128 | { | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | Carp::croak ref($self), " can't handle the input value '$value'"; | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 12 | ▶ | my $min_date = $self->field('min')->inflate_value($min) || $min; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->field('min')->inflate_value($min) || $min
MC/DC0%0/2
$self->field('min')->inflate_value($min) || $min
$self->field('min')->inflate_value($min)
$min
Truth table33%1/3
A || B
A= $self->field('min')->inflate_value($min)B= $min
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 12 | ▶ | my $max_date = $self->field('max')->inflate_value($max) || $max; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->field('max')->inflate_value($max) || $max
MC/DC0%0/2
$self->field('max')->inflate_value($max) || $max
$self->field('max')->inflate_value($max)
$max
Truth table33%1/3
A || B
A= $self->field('max')->inflate_value($max)B= $max
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | return | ||||||||||||||||||||||||||||||||||||||||||
| 136 | { | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 12 | min => $min_date, | |||||||||||||||||||||||||||||||||||||||||
| 138 | max => $max_date, | ||||||||||||||||||||||||||||||||||||||||||
| 139 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | sub inflate_value | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inflate_value: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 7 | my($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 7 | ▶ | if(ref $value eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | { | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 2 | $self->subfield_input_value(min => $value->[0]); | |||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | $self->subfield_input_value(max => $value->[1]); | |||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | #$self->field('min')->_set_input_value($value->[0]); | ||||||||||||||||||||||||||||||||||||||||||
| 152 | #$self->field('max')->_set_input_value($value->[1]); | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | return [ $self->field('min')->internal_value, $self->field('max')->internal_value ]; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | else | ||||||||||||||||||||||||||||||||||||||||||
| 157 | { | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 5 | my $values = $self->decompose_value($value); | |||||||||||||||||||||||||||||||||||||||||
| 159 | 5 | return [ $values->{'min'}, $values->{'max'} ]; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | ▶ | sub init_min_prefix_html { '' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_min_prefix_html: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | ▶ | sub init_max_prefix_html { '' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_max_prefix_html: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | ▶ | sub init_separator_html { ' - ' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_separator_html: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | sub html_field | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
html_field: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | return '<span class="date-range">' . | |||||||||||||||||||||||||||||||||||||||||
| 172 | $self->field('min')->html_label . $self->min_prefix_html . $self->field('min')->html_field . $self->separator_html . | ||||||||||||||||||||||||||||||||||||||||||
| 173 | $self->field('max')->html_label . $self->max_prefix_html . $self->field('max')->html_field . | ||||||||||||||||||||||||||||||||||||||||||
| 174 | '</span>'; | ||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | sub xhtml_field | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xhtml_field: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | return '<span class="date-range">' . | |||||||||||||||||||||||||||||||||||||||||
| 182 | $self->field('min')->xhtml_label . $self->min_prefix_html . $self->field('min')->xhtml_field . $self->separator_html . | ||||||||||||||||||||||||||||||||||||||||||
| 183 | $self->field('max')->xhtml_label . $self->max_prefix_html . $self->field('max')->xhtml_field . | ||||||||||||||||||||||||||||||||||||||||||
| 184 | '</span>'; | ||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | sub html | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
html: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 3 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 3 | ▶ | return '<table class="date-range">' . | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | '<tr><td class="min">' . | ||||||||||||||||||||||||||||||||||||||||||
| 193 | $self->field('min')->html_label . $self->min_prefix_html . $self->field('min')->html . '</td><td>' . $self->separator_html . '</td><td class="max">' . | ||||||||||||||||||||||||||||||||||||||||||
| 194 | $self->field('max')->html_label . $self->max_prefix_html . $self->field('max')->html . '</td></tr>' . | ||||||||||||||||||||||||||||||||||||||||||
| 195 | ($self->has_errors ? '<tr><td colspan="3">' . $self->html_errors . '</td></tr>' : '') . | ||||||||||||||||||||||||||||||||||||||||||
| 196 | '</table>'; | ||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | sub xhtml | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xhtml: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | ▶ | return '<table class="date-range">' . | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | '<tr><td class="min">' . | ||||||||||||||||||||||||||||||||||||||||||
| 205 | $self->field('min')->xhtml_label . $self->min_prefix_html . $self->field('min')->xhtml . '</td><td>' . $self->separator_html . '</td><td class="max">' . | ||||||||||||||||||||||||||||||||||||||||||
| 206 | $self->field('max')->xhtml_label . $self->max_prefix_html . $self->field('max')->xhtml . '</td></tr>' . | ||||||||||||||||||||||||||||||||||||||||||
| 207 | ($self->has_errors ? '<tr><td colspan="3">' . $self->xhtml_errors . '</td></tr>' : '') . | ||||||||||||||||||||||||||||||||||||||||||
| 208 | '</table>'; | ||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | sub validate | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate: called CC=9 SCAR=22.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 3 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 3 | my $ret = $self->SUPER::validate(@_); | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 3 | ▶ | return $ret unless($ret); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 3 | my @errors; | |||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 3 | foreach my $field (qw(min max)) | |||||||||||||||||||||||||||||||||||||||||
| 222 | { | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 6 | ▶ | unless($self->field($field)->validate) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | push(@errors, $self->field($field)->errors); | |||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | $self->field($field)->set_error; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 3 | ▶ | unless(@errors) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | { | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 2 | my($min, $max) = $self->internal_value; | |||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 2 | ▶ | if($min && $max && $min > $max) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$min and $max and $min > $max
$min and $max
MC/DC33%1/3
$min and $max and $min > $max
$min
$max
$min > $max
Truth table50%2/4
A and B and C
A= $minB= $maxC= $min > $max
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | $self->add_error_id(DATE_MIN_GREATER_THAN_MAX); | |||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 2 | ▶ | if(@errors) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | { | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | $self->add_errors(map { $_->clone } @errors); | |||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 2 | ▶ | if(__PACKAGE__->localizer->auto_load_messages) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | { | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | __PACKAGE__->localizer->load_all_messages; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 2 | ▶ | use utf8; # The __DATA__ section contains UTF-8 text | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | __DATA__ | ||||||||||||||||||||||||||||||||||||||||||