blib/lib/Valiemon/Attributes/Enum.pm

filter: Statementstmt 96.3% 26 / 27 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 2 totaltotal 82.6% 38 / 46 CC 3 SCAR 5.3
CC
3
Cov
88%
__ANON__
3.8
is_valid
1.0
BEGIN
1.0
CRAP 1.7
« blib/lib/Valiemon/Attributes/Pattern.pm ↑ Summary blib/lib/Valiemon/Attributes.pm »
1 package Valiemon::Attributes::Enum;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use parent qw(Valiemon::Attributes);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use List::MoreUtils qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 35 ▶sub attr_name { 'enum' }
Subroutine attr_name: called CC=1 SCAR=0.0
Pod undocumented
11  
12 sub is_valid {
13 35 ▶ my ($class, $context, $schema, $data) = @_;
Subroutine is_valid: called CC=1 SCAR=0.4
Pod undocumented
14  
15 35 my $enum = $schema->{enum};
16 $context->in_attr($class, sub {
17 35 ▶ if (ref $enum ne 'ARRAY' || scalar @$enum < 1) {
Subroutine __ANON__: called CC=3 SCAR=13.3
Branch: 1 branch
BranchTrueFalseTotal
if (ref $enum ne "ARRAY" or scalar @$enum < 1) 0 35 35
Condition33%1/3
ref $enum ne "ARRAY" or scalar @$enum < 1
l!l&&r!l&&!r
0035
MC/DC0%0/2
ref $enum ne "ARRAY" or scalar @$enum < 1
ref $enum ne "ARRAY" scalar @$enum < 1
Truth table33%1/3
A or B
A= ref $enum ne "ARRAY"B= scalar @$enum < 1
ABresult
1X1
011
000
18 0 croak sprintf '`enum` must be an array and have at leas one element at %s', $context->position
19 }
20  
21 35 ▶ any { $context->prims->is_equal($data, $_) } @$enum;
Subroutine __ANON__: called CC=1 SCAR=0.0
22 35 });
23 }
24  
25 3 1;
« blib/lib/Valiemon/Attributes/Pattern.pm ↑ Summary blib/lib/Valiemon/Attributes.pm »