FormValidator/Validator/Integer.pm

filter: Statementstmt 96.4% 27 / 28 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 90.4% 38 / 42 CC 3 SCAR 4.8
CC
3
Cov
94%
validate
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.6
« FormValidator/Validator/Min.pm ↑ Summary FormValidator/Processor.pm »
1 package Dancer2::Plugin::FormValidator::Validator::Integer;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Scalar::Util qw(looks_like_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 with 'Dancer2::Plugin::FormValidator::Role::Validator';
12  
13 sub message {
14 return {
15 1 ▶ en => '%s must be an integer',
Subroutine message: called CC=1 SCAR=0.0
Pod undocumented
16 ru => '%s должно содержать целочисленное значение',
17 de => '%s muss eine ganze Zahl sein',
18 };
19 }
20  
21 sub validate {
22 3 ▶ my ($self, $field, $input) = @_;
Subroutine validate: called CC=3 SCAR=11.2
Pod undocumented
23  
24 3 ▶ if ($self->_field_defined_and_non_empty($field, $input)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_field_defined_and_non_empty($field, $input)) 3 0 3
25 3 my $maybe_int = $input->{$field};
26  
27 3 ▶ if (looks_like_number($maybe_int)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&looks_like_number($maybe_int)) { } 2 1 3
28 2 return int($maybe_int) == $maybe_int;
29 }
30 else {
31 1 return 0;
32 }
33 }
34  
35 0 return 1;
36 }
37  
38 2 1;
« FormValidator/Validator/Min.pm ↑ Summary FormValidator/Processor.pm »