Syccess/Validator/Call.pm

filter: Statementstmt 100% 23 / 23 Branchbran 83.3% 10 / 12 Conditioncond 86.6% 13 / 15 MC/DCmcdc 37.5% 3 / 8 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 83.0% 54 / 65 CC 12 SCAR 17.9
CC
12
Cov
92%
validator
8.0
BUILD
5.7
BEGIN
1.0
CRAP 6.0
« Syccess/Validator/Length.pm ↑ Summary Syccess/Field.pm »
1 package Syccess::Validator::Call;
2 2 our $AUTHORITY = 'cpan:GETTY';
3 # ABSTRACT: A validator to check via call to a method
4 2 $Syccess::Validator::Call::VERSION = '0.104';
5 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 with qw(
9 Syccess::ValidatorSimple
10 );
11  
12 2 has not => (
13 is => 'ro',
14 predicate => 1,
15 );
16  
17 3 ▶sub BUILD {
Subroutine BUILD: called CC=5 SCAR=17.5
Pod undocumented
18 3 my ( $self ) = @_;
19 3 ▶ croak __PACKAGE__.' cant have arg and not'
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_arg and $self->has_not 0 3 3
Condition66%2/3
$self->has_arg and $self->has_not
!ll&&!rl&&r
210
MC/DC0%0/2
$self->has_arg and $self->has_not
$self->has_arg $self->has_not
Truth table66%2/3
A and B
A= $self->has_argB= $self->has_not
ABresult
0X0
100
111
20 if $self->has_arg and $self->has_not;
21 3 ▶ croak __PACKAGE__.' requires arg or not'
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_arg or $self->has_not 0 3 3
Condition66%2/3
$self->has_arg or $self->has_not
l!l&&r!l&&!r
120
MC/DC0%0/2
$self->has_arg or $self->has_not
$self->has_arg $self->has_not
Truth table66%2/3
A or B
A= $self->has_argB= $self->has_not
ABresult
1X1
011
000
22 unless $self->has_arg or $self->has_not;
23 }
24  
25 2 has message => (
26 is => 'lazy',
27 );
28  
29 2 ▶sub _build_message {
Subroutine _build_message: called CC=1 SCAR=0.0
30 2 return 'Your value for %s is not valid.';
31 }
32  
33 6 ▶sub validator {
Subroutine validator: called CC=8 SCAR=20.8
Pod undocumented
34 6 my ( $self, $value ) = @_;
35 # probably making function() possible, don't know yet how, as the
36 # function will be not available in my scope probably, and calling
37 # on main:: doesnt sound much of a "functionality"
38 6 ▶ my ( $thing, $method ) = @{$self->has_arg ? $self->arg : $self->not};
Branch: 1 branch
BranchTrueFalseTotal
$self->has_arg ? : 2 4 6
39 6 ▶ my $not = $self->has_not ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->has_not ? : 4 2 6
40 6 ▶ my $return = $thing->$method($value) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$thing->$method($value) ? : 3 3 6
41 6 ▶ return if ( $return and !$not ) or ( !$return and $not );
Branch: 1 branch
BranchTrueFalseTotal
if $return and CORE::not $not or CORE::not $return and $not 3 3 6
Condition100%9/9
$return and CORE::not $not or CORE::not $return and $not
l!l&&r!l&&!r
123
$return and CORE::not $not
!ll&&!rl&&r
321
CORE::not $return and $not
!ll&&!rl&&r
212
MC/DC75%3/4
$return and CORE::not $not or CORE::not $return and $not
$return CORE::not $not CORE::not $return $not
Truth table57%4/7
A and not(B) or not(C) and D
A= $returnB= CORE::not $notC= CORE::not $returnD= $not
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
42 3 return $self->message;
43 }
44  
45 2 1;
46  
47 __END__
« Syccess/Validator/Length.pm ↑ Summary Syccess/Field.pm »