FormValidator/Validator/Same.pm

filter: Statementstmt 92.8% 26 / 28 Branchbran 66.6% 4 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 79.5% 39 / 49 CC 5 SCAR 8.0
CC
5
Cov
84%
_is_same_as
3.8
validate
3.1
BEGIN
1.0
CRAP 2.2
« FormValidator.pm ↑ Summary FormValidator/Validator/Alpha.pm »
1 package Dancer2::Plugin::FormValidator::Validator::Same;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 with 'Dancer2::Plugin::FormValidator::Role::Validator';
11  
12 sub message {
13 return {
14 3 ▶ en => '%s must be the same as %s',
Subroutine message: called CC=1 SCAR=0.0
Pod undocumented
15 ru => '%s должно совпадать со значением %s',
16 de => '%s muss identisch mit %s sein',
17 };
18 }
19  
20 sub validate {
21 9 ▶ my ($self, $field, $input, $field2) = @_;
Subroutine validate: called CC=3 SCAR=11.2
Pod undocumented
22  
23 9 ▶ if ($self->_field_defined_and_non_empty($field, $input)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_field_defined_and_non_empty($field, $input)) 9 0 9
24 9 ▶ if (exists $input->{$field2}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $input->{$field2}) { } 8 1 9
25 8 return $self->_is_same_as($input->{$field}, $input->{$field2});
26 }
27 else {
28 1 return 0;
29 }
30 }
31  
32 0 return 1;
33 }
34  
35 sub _is_same_as {
36 8 ▶ my ($self, $value1, $value2) = @_;
Subroutine _is_same_as: called CC=3 SCAR=13.3
37  
38 8 ▶ if (defined $value1 and defined $value2) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value1 and defined $value2) 8 0 8
Condition33%1/3
defined $value1 and defined $value2
!ll&&!rl&&r
008
MC/DC0%0/2
defined $value1 and defined $value2
defined $value1 defined $value2
Truth table33%1/3
A and B
A= defined $value1B= defined $value2
ABresult
0X0
100
111
39 8 return $value1 eq $value2;
40 }
41  
42 0 return 0;
43 }
44  
45 4 1;
« FormValidator.pm ↑ Summary FormValidator/Validator/Alpha.pm »