| 1 | 27 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::Element::Date; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 27 | $HTML::FormFu::Element::Date::VERSION = '2.09'; | |||||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: 3 select menu multi-field | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 27 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 27 | ▶ | use MooseX::Attribute::Chained; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 27 | extends 'HTML::FormFu::Element::Multi'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 27 | ▶ | use HTML::FormFu::Util qw( _filter_components _parse_args ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 27 | ▶ | use DateTime; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 27 | ▶ | use DateTime::Format::Builder; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 27 | ▶ | use DateTime::Format::Natural; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 27 | ▶ | use DateTime::Locale; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 27 | ▶ | use Moose::Util qw( apply_all_roles ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 27 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 27 | ▶ | use List::Util 1.45 qw( all none uniq ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 27 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 27 | __PACKAGE__->mk_attrs(qw( day month year )); | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 27 | has auto_inflate => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||||||||||||
| 25 | 27 | has default_natural => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||||||||||||
| 26 | 27 | has default_datetime_args => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||||||||||||
| 27 | 27 | has printf_day => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||||||||||||
| 28 | 27 | has printf_month => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||||||||||||
| 29 | 27 | has printf_year => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 27 | has _known_fields => ( is => 'rw' ); | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 27 | has strftime => ( | |||||||||||||||||||||||||||||||||||||||||
| 34 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | default => '%d-%m-%Y', | ||||||||||||||||||||||||||||||||||||||||||
| 36 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 37 | traits => ['Chained'], | ||||||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 27 | *default = \&value; | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | # build get_Xs methods | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 27 | for my $method ( qw( | |||||||||||||||||||||||||||||||||||||||||
| 44 | deflator filter | ||||||||||||||||||||||||||||||||||||||||||
| 45 | constraint inflator | ||||||||||||||||||||||||||||||||||||||||||
| 46 | validator transformer | ||||||||||||||||||||||||||||||||||||||||||
| 47 | ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 109 | ▶ | my $sub = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 109 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 109 | my %args = _parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 52 | 109 | my $get_method = "get_${method}s"; | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 109 | my $accessor = "_${method}s"; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 109 | my @x = @{ $self->$accessor }; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 109 | push @x, map { @{ $_->$get_method(@_) } } @{ $self->_elements }; | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 109 | return _filter_components( \%args, \@x ); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 162 | }; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 162 | my $name = __PACKAGE__ . "::get_${method}s"; | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | ## no critic (ProhibitNoStrict); | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 27 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 162 | *{$name} = $sub; | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 42 | ▶ | after BUILD => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 42 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 42 | $self->printf_day('%d'); | |||||||||||||||||||||||||||||||||||||||||
| 73 | 42 | $self->printf_month('%d'); | |||||||||||||||||||||||||||||||||||||||||
| 74 | 42 | $self->printf_year('%d'); | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 42 | $self->_known_fields( [qw( day month year )] ); | |||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 42 | $self->field_order( [qw( day month year )] ); | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 42 | $self->day( { prefix => [], } ); | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 42 | $self->month( { prefix => [], } ); | |||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 42 | $self->year( | |||||||||||||||||||||||||||||||||||||||||
| 85 | { prefix => [], | ||||||||||||||||||||||||||||||||||||||||||
| 86 | less => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 87 | plus => 10, | ||||||||||||||||||||||||||||||||||||||||||
| 88 | reverse => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 42 | return; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 27 | }; | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 174 | ▶ | sub value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 174 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 174 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 27 | $self->{value} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | # if we're already built - i.e. process() has ben called, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | # call default() on our children | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 27 | ▶ | if ( @{ $self->_elements } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 7 | $self->_date_defaults; | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 7 | my @order = @{ $self->field_order }; | |||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 7 | for my $i ( 0 .. $#order ) { | |||||||||||||||||||||||||||||||||||||||||
| 109 | 31 | my $field = $order[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 31 | my $printf_method = "printf_$field"; | |||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | my $default | ||||||||||||||||||||||||||||||||||||||||||
| 114 | = $value | ||||||||||||||||||||||||||||||||||||||||||
| 115 | ? sprintf( $self->$printf_method, $self->$field->{default} ) | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 31 | ▶ | : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 31 | $self->_elements->[$i]->default($default); | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 27 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 147 | return $self->{value}; | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 49 | ▶ | sub _add_elements { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_elements: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 49 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 49 | $self->_elements( [] ); | |||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 49 | $self->_date_defaults; | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 49 | for my $order ( @{ $self->field_order } ) { | |||||||||||||||||||||||||||||||||||||||||
| 136 | 178 | my $method = "_add_$order"; | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 178 | $self->$method; | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 49 | ▶ | if ( $self->auto_inflate | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->auto_inflate and not @{$self->get_inflators({"type", "DateTime"});}
MC/DC100%2/2
$self->auto_inflate and not @{$self->get_inflators({"type", "DateTime"});}
$self->auto_inflate
not @{$self->get_inflators({"type", "DateTime"});}
Truth table100%3/3
A and not(B)
A= $self->auto_inflateB= not @{$self->get_inflators({"type", "DateTime"});}
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 20 | && !@{ $self->get_inflators( { type => "DateTime" } ) } ) | |||||||||||||||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 10 | _add_inflator($self); | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 49 | return; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 56 | ▶ | sub _date_defaults { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_date_defaults: called CC=16 SCAR=27.8
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 56 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 56 | my $default; | |||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 56 | ▶ | if ( defined( $default = $self->default ) && length $default ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined($default = $self->default) and length $default
MC/DC100%2/2
defined($default = $self->default) and length $default
defined($default = $self->default)
length $default
Truth table100%3/3
A and B
A= defined($default = $self->default)B= length $default
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 38 | ▶ | if ( !$self->form->submitted || $self->render_processed_value ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $self->form->submitted or $self->render_processed_value
MC/DC50%1/2
not $self->form->submitted or $self->render_processed_value
not $self->form->submitted
$self->render_processed_value
Truth table66%2/3
not(A) or B
A= not $self->form->submittedB= $self->render_processed_value
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 32 | for my $deflator ( @{ $self->_deflators } ) { | |||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | $default = $deflator->process($default); | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 38 | my $is_blessed = blessed($default); | |||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 38 | ▶ | if ( !$is_blessed || ( $is_blessed && !$default->isa('DateTime') ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
not $is_blessed or $is_blessed and not $default->isa("DateTime")
$is_blessed and not $default->isa("DateTime")
MC/DC33%1/3
not $is_blessed or $is_blessed and not $default->isa("DateTime")
not $is_blessed
$is_blessed
not $default->isa("DateTime")
Truth table50%2/4
not(A) or B and not(C)
A= not $is_blessedB= $is_blessedC= not $default->isa("DateTime")
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 19 | my $builder = DateTime::Format::Builder->new; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 19 | $builder->parser( { strptime => $self->strftime } ); | |||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 19 | $default = $builder->parse_datetime($default); | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | elsif ( defined( $default = $self->default_natural ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | my $parser; | |||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 3 | ▶ | if ( defined( my $datetime_args = $self->default_datetime_args ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | ▶ | if ( exists $datetime_args->{set_time_zone} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | my $tz = $datetime_args->{set_time_zone}; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | $parser = DateTime::Format::Natural->new( time_zone => $tz ); | |||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | $parser = DateTime::Format::Natural->new; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | $parser = DateTime::Format::Natural->new; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 3 | $default = $parser->parse_datetime($default); | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 15 | $default = undef; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 56 | ▶ | if ( defined $default ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 41 | ▶ | if ( defined( my $datetime_args = $self->default_datetime_args ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 2 | for my $key ( keys %$datetime_args ) { | |||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | $default->$key( $datetime_args->{$key} ); | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 41 | for my $field ( @{ $self->field_order } ) { | |||||||||||||||||||||||||||||||||||||||||
| 202 | 153 | $self->$field->{default} = $default->$field; | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 56 | return; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 45 | ▶ | sub _add_day { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_day: called CC=5 SCAR=16.9
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 45 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 45 | my $day = $self->day; | |||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 45 | my $day_name = $self->_build_name('day'); | |||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | my @day_prefix | ||||||||||||||||||||||||||||||||||||||||||
| 217 | = ref $day->{prefix} | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 33 | ? @{ $day->{prefix} } | |||||||||||||||||||||||||||||||||||||||||
| 219 | 45 | ▶ | : $day->{prefix}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 45 | ▶ | if ( exists $day->{prefix_loc} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | @day_prefix | ||||||||||||||||||||||||||||||||||||||||||
| 223 | = ref $day->{prefix_loc} | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ? map { $self->form->localize($_) } @{ $day->{prefix_loc} } | |||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | : $self->form->localize( $day->{prefix_loc} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 45 | @day_prefix = map { [ '', $_ ] } @day_prefix; | |||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | my $element = $self->element( | ||||||||||||||||||||||||||||||||||||||||||
| 231 | { type => 'Select', | ||||||||||||||||||||||||||||||||||||||||||
| 232 | name => $day_name, | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 1395 | ▶ | options => [ @day_prefix, map { [ $_, $_ ] } 1 .. 31 ], | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | attributes => $day->{attributes}, | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 45 | defined $day->{default} ? ( default => $day->{default} ) : (), | |||||||||||||||||||||||||||||||||||||||||
| 237 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 45 | apply_all_roles( $element, 'HTML::FormFu::Role::Element::MultiElement' ); | |||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 45 | return; | |||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 49 | ▶ | sub _add_month { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_month: called CC=5 SCAR=16.8
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 49 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 49 | my $month = $self->month; | |||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 49 | my $month_name = $self->_build_name('month'); | |||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 49 | my @months = _build_month_list($self); | |||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | my @month_prefix | ||||||||||||||||||||||||||||||||||||||||||
| 254 | = ref $month->{prefix} | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 35 | ? @{ $month->{prefix} } | |||||||||||||||||||||||||||||||||||||||||
| 256 | 49 | ▶ | : $month->{prefix}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 49 | ▶ | if ( exists $month->{prefix_loc} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | @month_prefix | ||||||||||||||||||||||||||||||||||||||||||
| 260 | = ref $month->{prefix_loc} | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ? map { $self->form->localize($_) } @{ $month->{prefix_loc} } | |||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | : $self->form->localize( $month->{prefix_loc} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 49 | @month_prefix = map { [ '', $_ ] } @month_prefix; | |||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 49 | my $options = [ @month_prefix, map { [ $_ + 1, $months[$_] ] } 0 .. 11 ]; | |||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | my $element = $self->element( | ||||||||||||||||||||||||||||||||||||||||||
| 270 | { type => 'Select', | ||||||||||||||||||||||||||||||||||||||||||
| 271 | name => $month_name, | ||||||||||||||||||||||||||||||||||||||||||
| 272 | options => $options, | ||||||||||||||||||||||||||||||||||||||||||
| 273 | attributes => $month->{attributes}, | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 49 | ▶ | defined $month->{default} ? ( default => $month->{default} ) : (), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 49 | apply_all_roles( $element, 'HTML::FormFu::Role::Element::MultiElement' ); | |||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 49 | return; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 49 | ▶ | sub _add_year { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_year: called CC=8 SCAR=21.2
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 49 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 49 | my $year = $self->year; | |||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 49 | my $year_name = $self->_build_name('year'); | |||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | my $year_ref | ||||||||||||||||||||||||||||||||||||||||||
| 291 | = defined $year->{reference} | ||||||||||||||||||||||||||||||||||||||||||
| 292 | ? $year->{reference} | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 49 | ▶ | : ( localtime(time) )[5] + 1900; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | my @years | ||||||||||||||||||||||||||||||||||||||||||
| 296 | = defined $year->{list} | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 36 | ? @{ $year->{list} } | |||||||||||||||||||||||||||||||||||||||||
| 298 | 49 | ▶ | : ( $year_ref - $year->{less} ) .. ( $year_ref + $year->{plus} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 49 | ▶ | if ( $year->{reverse} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | 1 | @years = reverse(@years); | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | my @year_prefix | ||||||||||||||||||||||||||||||||||||||||||
| 305 | = ref $year->{prefix} | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 35 | ? @{ $year->{prefix} } | |||||||||||||||||||||||||||||||||||||||||
| 307 | 49 | ▶ | : $year->{prefix}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 49 | ▶ | if ( exists $year->{prefix_loc} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | @year_prefix | ||||||||||||||||||||||||||||||||||||||||||
| 311 | = ref $year->{prefix_loc} | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ? map { $self->form->localize($_) } @{ $year->{prefix_loc} } | |||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | : $self->form->localize( $year->{prefix_loc} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 49 | @year_prefix = map { [ '', $_ ] } @year_prefix; | |||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | my $element = $self->element( | ||||||||||||||||||||||||||||||||||||||||||
| 319 | { type => 'Select', | ||||||||||||||||||||||||||||||||||||||||||
| 320 | name => $year_name, | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 425 | ▶ | options => [ @year_prefix, map { [ $_, $_ ] } @years ], | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | attributes => $year->{attributes}, | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 49 | defined $year->{default} ? ( default => $year->{default} ) : (), | |||||||||||||||||||||||||||||||||||||||||
| 325 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 49 | apply_all_roles( $element, 'HTML::FormFu::Role::Element::MultiElement' ); | |||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 49 | return; | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 49 | ▶ | sub _build_month_list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_month_list: called CC=6 SCAR=18.4
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 49 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 49 | my $month = $self->month; | |||||||||||||||||||||||||||||||||||||||||
| 336 | 49 | my @months; | |||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 49 | ▶ | if ( defined $month->{names} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | @months = @{ $month->{names} }; | |||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 49 | my $languages = $self->form->languages; | |||||||||||||||||||||||||||||||||||||||||
| 343 | 49 | ▶ | if ( ref $languages ne 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $languages = [$languages]; | |||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 49 | for my $lang (@$languages) { | |||||||||||||||||||||||||||||||||||||||||
| 348 | 49 | my $loc; | |||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 49 | eval { $loc = DateTime::Locale->load($lang) }; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 49 | ▶ | if ( !$@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | @months | ||||||||||||||||||||||||||||||||||||||||||
| 353 | = $month->{short_names} | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 14 | ? @{ $loc->month_format_abbreviated } | |||||||||||||||||||||||||||||||||||||||||
| 355 | 49 | ▶ | : @{ $loc->month_format_wide }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 49 | @months = map {ucfirst} @months; | |||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 49 | last; | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 49 | return @months; | |||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 19 | ▶ | sub _build_number_list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_number_list: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 19 | my ( $self, $start, $end, $interval ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 19 | ▶ | $interval ||= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$interval ||= 1
MC/DC100%1/1
$interval ||= 1
$interval
Truth table100%2/2
A
A= $interval
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 19 | my @list; | |||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 19 | ▶ | for ( my $i = $start; $i <= $end; $i += $interval ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 1034 | push @list, $i; | |||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 19 | return @list; | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | 178 | ▶ | sub _build_name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_name: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | 178 | my ( $self, $type ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | 178 | ▶ | return $self->$type->{name} if defined $self->$type->{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | # a Date element without a name has unnamed sub-fields | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 178 | ▶ | return if !defined $self->name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | 172 | return sprintf "%s_%s", $self->name, $type; | |||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 10 | ▶ | sub _add_inflator { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_inflator: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 10 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 10 | $self->inflator( | |||||||||||||||||||||||||||||||||||||||||
| 396 | { type => "DateTime", | ||||||||||||||||||||||||||||||||||||||||||
| 397 | parser => { strptime => $self->strftime, }, | ||||||||||||||||||||||||||||||||||||||||||
| 398 | strptime => $self->strftime, | ||||||||||||||||||||||||||||||||||||||||||
| 399 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 10 | return; | |||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | 176 | ▶ | sub field_order { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
field_order: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | 176 | my ( $self, @order ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 176 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | 61 | ▶ | if ( @order == 1 && ref( $order[0] ) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@order == 1 and ref $order[0] eq "ARRAY"
MC/DC0%0/2
@order == 1 and ref $order[0] eq "ARRAY"
@order == 1
ref $order[0] eq "ARRAY"
Truth table33%1/3
A and B
A= @order == 1B= ref $order[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 61 | @order = @{ $order[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 61 | for my $field (@order) { | |||||||||||||||||||||||||||||||||||||||||
| 413 | croak "unknown field type: '$field'" | ||||||||||||||||||||||||||||||||||||||||||
| 414 | 209 | ▶ | if none { $field eq $_ } @{ $self->_known_fields }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 60 | ▶ | croak 'repeated field type' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | if scalar( uniq @order ) != scalar(@order); | ||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 59 | $self->{field_order} = \@order; | |||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 59 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 424 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 425 | 115 | return $self->{field_order}; | |||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 49 | ▶ | sub process { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 49 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | 49 | $self->_add_elements; | |||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 49 | return $self->SUPER::process(@args); | |||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | 19 | ▶ | sub process_input { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_input: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 19 | my ( $self, $input ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | # a Date element without a name has no input to combine | ||||||||||||||||||||||||||||||||||||||||||
| 441 | 19 | ▶ | return $self->SUPER::process_input($input) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | if !defined $self->nested_name; | ||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 18 | my %value; | |||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | 18 | my @order = @{ $self->field_order }; | |||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | 18 | for my $i ( 0 .. $#order ) { | |||||||||||||||||||||||||||||||||||||||||
| 449 | 63 | my $field = $order[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 63 | my $name = $self->_elements->[$i]->nested_name; | |||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 63 | $value{$field} = $self->get_nested_hash_value( $input, $name ); | |||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 18 | ▶ | if ( ( all {defined} values %value ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
Condition100%3/3
&all(sub {
defined $_;
}
, values %value) and &all(sub {
length $_;
}
, values %value)
MC/DC100%2/2
&all(sub {
defined $_;
}
, values %value) and &all(sub {
length $_;
}
, values %value)
&all(sub {
defined $_;
}
, values %value)
&all(sub {
length $_;
}
, values %value)
Truth table100%3/3
A and B
A= &all(sub {
defined $_;
}
, values %value)B= &all(sub {
length $_;
}
, values %value)
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | 50 | ▶ | && all {length} values %value ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | { | ||||||||||||||||||||||||||||||||||||||||||
| 459 | 14 | my $dt; | |||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 14 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 462 | 14 | $dt = DateTime->new( map { $_, $value{$_} } keys %value ); | |||||||||||||||||||||||||||||||||||||||||
| 463 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 14 | my $value; | |||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | 14 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | 3 | $value = $self->strftime; | |||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||
| 470 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 471 | 11 | $value = $dt->strftime( $self->strftime ); | |||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 14 | $self->set_nested_hash_value( $input, $self->nested_name, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 18 | return $self->SUPER::process_input($input); | |||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | 49 | ▶ | sub render_data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_data: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 481 | 49 | return shift->render_data_non_recursive(@_); | |||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | 49 | ▶ | sub render_data_non_recursive { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_data_non_recursive: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 49 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | my $render = $self->SUPER::render_data_non_recursive( | ||||||||||||||||||||||||||||||||||||||||||
| 488 | 49 | ▶ | { elements => [ map { $_->render_data } @{ $self->_elements } ], | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 489 | $args ? %$args : (), | ||||||||||||||||||||||||||||||||||||||||||
| 490 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | 49 | return $render; | |||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | 27 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | 27 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | __END__ | ||||||||||||||||||||||||||||||||||||||||||