| 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
Condition66%2/3
$self->has_arg and $self->has_not
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | if $self->has_arg and $self->has_not; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | croak __PACKAGE__.' requires arg or not' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->has_arg or $self->has_not
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 6 | ▶ | my $not = $self->has_not ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 6 | ▶ | my $return = $thing->$method($value) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 6 | ▶ | return if ( $return and !$not ) or ( !$return and $not ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$return and CORE::not $not or CORE::not $return and $not
$return and CORE::not $not
CORE::not $return and $not
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 3 | return $self->message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||