blib/lib/HTML/FormHandler/Field/Date/Infinite.pm

filter: Statementstmt 76.9% 20 / 26 Branchbran 50.0% 4 / 8 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 83.3% 5 / 6 Podpod n/a totaltotal 71.1% 32 / 45 CC 6 SCAR 16.3
CC
6
Cov
70%
_my_date_deflate
12.0
__ANON__
4.0
BEGIN
1.0
CRAP 5.1
↑ Summary
1 package HTML::FormHandler::Field::Date::Infinite;
2  
3 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 extends 'HTML::FormHandler::Field::Date';
5  
6 2 ▶use version; our $VERSION = qv('0.1.3');
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 has 'deflate_method' => ( is => "ro",
9 3 ▶ default => sub { \&_my_date_deflate } );
Subroutine __ANON__: called CC=1 SCAR=0.0
10  
11 0 ▶sub _my_date_deflate {
Subroutine _my_date_deflate: not called CC=3 SCAR=24.8
12  
13 0 my ( $self, $value ) = @_;
14  
15 0 ▶ if ($value->is_infinite) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->is_infinite) { } 0 0 0
16 ## plain stringification
17 0 ▶ if ( $value->isa("DateTime::Infinite::Future")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa('DateTime::Infinite::Future')) { } 0 0 0
18 0 return "infinity";
19 }
20 else {
21 0 return "-infinity";
22 }
23 }
24 else {
25 0 return HTML::FormHandler::Field::Date::date_deflate($self,$value);
26 }
27  
28 };
29  
30 6 ▶override 'validate' => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
31  
32 6 my $self = shift;
33  
34 6 ▶ if ( $self->value and $self->value =~ /^(-?inf)(?:init[ey])?$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->value and $self->value =~ /^(-?inf)(?:init[ey])?$/i) { } 5 1 6
Condition66%2/3
$self->value and $self->value =~ /^(-?inf)(?:init[ey])?$/i
!ll&&!rl&&r
015
MC/DC50%1/2
$self->value and $self->value =~ /^(-?inf)(?:init[ey])?$/i
$self->value $self->value =~ /^(-?inf)(?:init[ey])?$/i
Truth table66%2/3
A and B
A= $self->valueB= $self->value =~ /^(-?inf)(?:init[ey])?$/i
ABresult
0X0
100
111
35 5 ▶ return $self->_set_value( lc $1 eq "-inf" ? DateTime::Infinite::Past->new : DateTime::Infinite::Future->new );
Branch: 1 branch
BranchTrueFalseTotal
lc $1 eq '-inf' ? : 2 3 5
36 }
37 else {
38 1 return super();
39 }
40  
41 2 };
42  
43 2 __PACKAGE__->meta->make_immutable;
44 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 2 1; # Magic true value required at end of module
47 __END__
↑ Summary