lib/HTML/FormFu/Constraint/Range.pm

filter: Statementstmt 93.5% 29 / 31 Branchbran 83.3% 10 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 82.1% 46 / 56 CC 8 SCAR 16.6
CC
8
Cov
87%
constrain_value
8.3
_localize_args
2.0
BEGIN
1.0
CRAP 5.3
« lib/HTML/FormFu/Inflator/DateTime.pm ↑ Summary lib/HTML/FormFu/Role/Element/Input.pm »
1 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Constraint::Range;
4 8 $HTML::FormFu::Constraint::Range::VERSION = '2.09';
5 # ABSTRACT: Numerical Range Constraint
6  
7 8 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use MooseX::Attribute::Chained;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use MooseX::Aliases;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 8 extends 'HTML::FormFu::Constraint';
12  
13 8 ▶use Scalar::Util qw( looks_like_number );
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 8 has minimum => (
16 is => 'rw',
17 alias => 'min',
18 traits => ['Chained'],
19 );
20  
21 8 has maximum => (
22 is => 'rw',
23 alias => 'max',
24 traits => ['Chained'],
25 );
26  
27 12 ▶sub constrain_value {
Subroutine constrain_value: called CC=8 SCAR=21.2
Pod undocumented
28 12 my ( $self, $value ) = @_;
29  
30 12 ▶ return 1 if !defined $value || $value eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value or $value eq "" 0 12 12
Condition33%1/3
not defined $value or $value eq ""
l!l&&r!l&&!r
0012
MC/DC0%0/2
not defined $value or $value eq ""
not defined $value $value eq ""
Truth table33%1/3
not(A) or B
A= not defined $valueB= $value eq ""
ABresult
1X1
011
000
31  
32 12 ▶ return if !looks_like_number($value);
Branch: 1 branch
BranchTrueFalseTotal
unless &looks_like_number($value) 0 12 12
33  
34 12 ▶ if ( defined( my $min = $self->minimum ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $min = $self->minimum)) 8 4 12
35 8 ▶ return 0 if $value < $min;
Branch: 1 branch
BranchTrueFalseTotal
if $value < $min 2 6 8
36 }
37  
38 10 ▶ if ( defined( my $max = $self->maximum ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $max = $self->maximum)) 7 3 10
39 7 ▶ return 0 if $value > $max;
Branch: 1 branch
BranchTrueFalseTotal
if $value > $max 2 5 7
40 }
41  
42 8 return 1;
43 }
44  
45 0 ▶sub _localize_args {
Subroutine _localize_args: not called CC=1 SCAR=6.9
46 0 my ($self) = @_;
47  
48 0 return $self->min, $self->max;
49 }
50  
51 8 __PACKAGE__->meta->make_immutable;
52  
53 8 1;
54  
55 __END__
« lib/HTML/FormFu/Inflator/DateTime.pm ↑ Summary lib/HTML/FormFu/Role/Element/Input.pm »