blib/lib/Valiemon/Attributes/Type.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 4 / 4 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 2 totaltotal 96.0% 48 / 50 CC 4 SCAR 4.8
CC
4
Cov
100%
_check
3.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.6
« blib/lib/Valiemon/Attributes/Format.pm ↑ Summary blib/lib/Valiemon/Context.pm »
1 package Valiemon::Attributes::Type;
2 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use parent qw(Valiemon::Attributes);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 18 ▶use List::MoreUtils qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 435 ▶sub attr_name { 'type' }
Subroutine attr_name: called CC=1 SCAR=0.0
Pod undocumented
10  
11 sub is_valid {
12 435 ▶ my ($class, $context, $schema, $data) = @_;
Subroutine is_valid: called CC=1 SCAR=0.0
Pod undocumented
13 $context->in_attr($class, sub {
14 435 ▶ my $types = $schema->{type};
Subroutine __ANON__: called CC=2 SCAR=6.9
15  
16 435 my $is_valid = do {
17 435 ▶ if (ref $types eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $types eq 'ARRAY') { } 30 405 435
18 30 ▶ any { $class->_check($context->prims, $_, $data) } @$types
Subroutine __ANON__: called CC=1 SCAR=0.0
19 } else {
20 405 $class->_check($context->prims, $types, $data);
21 }
22 };
23 435 $is_valid;
24 435 });
25 }
26  
27 sub _check {
28 460 ▶ my ($class, $prims, $type, $data) = @_;
Subroutine _check: called CC=3 SCAR=11.0
29 460 my $method = 'is_' . $type;
30 460 ▶ $prims->can($method) && $prims->$method($data) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$prims->can($method) && $prims->$method($data) ? : 281 179 460
Condition100%3/3
$prims->can($method) and $prims->$method($data)
!ll&&!rl&&r
21158281
MC/DC100%2/2
$prims->can($method) and $prims->$method($data)
$prims->can($method) $prims->$method($data)
Truth table100%3/3
A and B
A= $prims->can($method)B= $prims->$method($data)
ABresult
0X0
100
111
31 }
32  
33 18 1;
« blib/lib/Valiemon/Attributes/Format.pm ↑ Summary blib/lib/Valiemon/Context.pm »