lib/HTML/FormFu/Constraint/Length.pm

filter: Statementstmt 92.5% 25 / 27 Branchbran 90.0% 9 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 81.6% 40 / 49 CC 7 SCAR 15.4
CC
7
Cov
88%
constrain_value
7.2
_localize_args
2.0
BEGIN
1.0
CRAP 4.7
« lib/HTML/FormFu/Role/Filter/Compound.pm ↑ Summary lib/HTML/FormFu/Element/DateTime.pm »
1 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Constraint::Length;
4 11 $HTML::FormFu::Constraint::Length::VERSION = '2.09';
5 # ABSTRACT: Min/Max Length String Constraint
6  
7 11 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use MooseX::Attribute::Chained;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use MooseX::Aliases;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 11 extends 'HTML::FormFu::Constraint';
12  
13 11 has minimum => (
14 is => 'rw',
15 alias => 'min',
16 traits => ['Chained'],
17 );
18  
19 11 has maximum => (
20 is => 'rw',
21 alias => 'max',
22 traits => ['Chained'],
23 );
24  
25 15 ▶sub constrain_value {
Subroutine constrain_value: called CC=7 SCAR=19.7
Pod undocumented
26 15 my ( $self, $value ) = @_;
27  
28 15 ▶ return 1 if !defined $value || $value eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value or $value eq "" 0 15 15
Condition33%1/3
not defined $value or $value eq ""
l!l&&r!l&&!r
0015
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
29  
30 15 ▶ if ( defined( my $min = $self->minimum ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $min = $self->minimum)) 9 6 15
31 9 ▶ return 0 if length $value < $min;
Branch: 1 branch
BranchTrueFalseTotal
if length $value < $min 3 6 9
32 }
33  
34 12 ▶ if ( defined( my $max = $self->maximum ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $max = $self->maximum)) 9 3 12
35 9 ▶ return 0 if length $value > $max;
Branch: 1 branch
BranchTrueFalseTotal
if length $value > $max 4 5 9
36 }
37  
38 8 return 1;
39 }
40  
41 0 ▶sub _localize_args {
Subroutine _localize_args: not called CC=1 SCAR=6.9
42 0 my ($self) = @_;
43  
44 0 return $self->min, $self->max;
45 }
46  
47 11 __PACKAGE__->meta->make_immutable;
48  
49 11 1;
50  
51 __END__
« lib/HTML/FormFu/Role/Filter/Compound.pm ↑ Summary lib/HTML/FormFu/Element/DateTime.pm »