lib/HTML/FormFu/Constraint/Number.pm

filter: Statementstmt 100% 17 / 17 Branchbran 75.0% 3 / 4 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 93.5% 29 / 31 SCAR 13.9
CC
4
Cov
96%
constrain_value
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« lib/HTML/FormFu/Role/Element/NonBlock.pm ↑ Summary lib/HTML/FormFu/Upload.pm »
1 27 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Constraint::Number;
4 27 $HTML::FormFu::Constraint::Number::VERSION = '2.06';
5 # ABSTRACT: Numerical Constraint
6  
7 27 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 27 extends 'HTML::FormFu::Constraint';
9  
10 27 ▶use Scalar::Util qw( looks_like_number );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub constrain_value {
13 77 ▶ my ( $self, $value ) = @_;
Subroutine constrain_value: called CC=4 SCAR=13.9
Pod undocumented
14  
15 77 ▶ return 1 if !defined $value || $value eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value or $value eq "" 3 74 77
Condition100%3/3
not defined $value or $value eq ""
l!l&&r!l&&!r
1274
MC/DC100%2/2
not defined $value or $value eq ""
not defined $value $value eq ""
Truth table100%3/3
not(A) or B
A= not defined $valueB= $value eq ""
ABresult
1X1
011
000
16  
17 74 my $ok = looks_like_number($value);
18  
19 74 ▶ return $self->not ? !$ok : $ok;
Branch: 1 branch
BranchTrueFalseTotal
$self->not ? : 0 74 74
20 }
21  
22 27 __PACKAGE__->meta->make_immutable;
23  
24 27 1;
25  
26 __END__
27  
28 =pod
29  
30 =encoding UTF-8
31  
32 =head1 NAME
33  
34 HTML::FormFu::Constraint::Number - Numerical Constraint
35  
36 =head1 VERSION
37  
38 version 2.06
39  
40 =head1 DESCRIPTION
41  
42 The input must be a number.
43  
44 =head1 SEE ALSO
45  
46 Is a sub-class of, and inherits methods from L<HTML::FormFu::Constraint>
47  
48 L<HTML::FormFu>
49  
50 =head1 AUTHOR
51  
52 Carl Franks C<cfranks@cpan.org>
53  
54 =head1 LICENSE
55  
56 This library is free software, you can redistribute it and/or modify it under
57 the same terms as Perl itself.
58  
59 =head1 AUTHOR
60  
61 Carl Franks <cpan@fireartist.com>
62  
63 =head1 COPYRIGHT AND LICENSE
64  
65 This software is copyright (c) 2018 by Carl Franks.
66  
67 This is free software; you can redistribute it and/or modify it under
68 the same terms as the Perl 5 programming language system itself.
69  
70 =cut
« lib/HTML/FormFu/Role/Element/NonBlock.pm ↑ Summary lib/HTML/FormFu/Upload.pm »