Rx/CoreType/any.pm

filter: Statementstmt 100% 35 / 35 Branchbran 90.0% 9 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 90.0% 54 / 60 CC 8 SCAR 11.9
CC
8
Cov
96%
guts_from_arg
5.0
assert_valid
4.0
BEGIN
1.0
CRAP 3.3
« Rx/CoreType/all.pm ↑ Summary Rx/CoreType/map.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Data::Rx::CoreType::any;
4 # ABSTRACT: the Rx //any type
5 1 $Data::Rx::CoreType::any::VERSION = '0.200007';
6 1 ▶use parent 'Data::Rx::CoreType';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub guts_from_arg {
11 5 ▶ my ($class, $arg, $rx, $type) = @_;
Subroutine guts_from_arg: called CC=5 SCAR=16.2
Pod undocumented
12  
13 5 ▶ Carp::croak("unknown arguments to new")
Branch: 1 branch
BranchTrueFalseTotal
unless "Data::Rx::Util"->_x_subset_keys_y($arg, {"of", 1}) 0 5 5
14 unless Data::Rx::Util->_x_subset_keys_y($arg, { of => 1});
15  
16 5 my $guts = {};
17  
18 5 ▶ if (my $of = $arg->{of}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $of = $arg->{"of"}) 2 3 5
19 2 ▶ Carp::croak("invalid 'of' argument to //any") unless
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::reftype($of) eq "ARRAY" and @$of 1 1 2
Condition66%2/3
builtin::reftype($of) eq "ARRAY" and @$of
!ll&&!rl&&r
011
MC/DC50%1/2
builtin::reftype($of) eq "ARRAY" and @$of
builtin::reftype($of) eq "ARRAY" @$of
Truth table66%2/3
A and B
A= builtin::reftype($of) eq "ARRAY"B= @$of
ABresult
0X0
100
111
20 Scalar::Util::reftype $of eq 'ARRAY' and @$of;
21  
22 1 $guts->{of} = [ map {; $rx->make_schema($_) } @$of ];
23 }
24  
25 4 return $guts;
26 }
27  
28 sub assert_valid {
29 120 ▶ return 1 unless $_[0]->{of};
Subroutine assert_valid: called CC=4 SCAR=13.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]{"of"} 66 54 120
30  
31 54 my ($self, $value) = @_;
32  
33 54 my @failures;
34 54 for my $i (0 .. $#{ $self->{of} }) {
35 106 my $check = $self->{of}[ $i ];
36 106 ▶ return 1 if eval { $check->assert_valid($value) };
Branch: 1 branch
BranchTrueFalseTotal
if eval { do { $check->assert_valid($value) } } 3 103 106
37  
38 103 my $failure = $@;
39 103 $failure->contextualize({
40 type => $self->type,
41 check_path => [ [ 'of', 'key'], [ $i, 'index' ] ],
42 });
43  
44 103 push @failures, $failure;
45 }
46  
47 $self->fail({
48 51 error => [ qw(none) ],
49 message => "matched none of the available alternatives",
50 value => $value,
51 failures => \@failures,
52 });
53 }
54  
55 54 ▶sub subname { 'any' }
Subroutine subname: called CC=1 SCAR=0.0
Pod undocumented
56  
57 1 1;
58  
59 __END__
« Rx/CoreType/all.pm ↑ Summary Rx/CoreType/map.pm »