Valiant/Proxy/Array.pm

filter: Statementstmt 100% 10 / 10 Branchbran 100% 2 / 2 Conditioncond 66.6% 4 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 2 / 2 Podpod 0.0% 0 / 1 totaltotal 79.1% 19 / 24 CC 4 SCAR 12.4
CC
4
Cov
89%
read_attribute_for_validation
4.1
BEGIN
1.0
CRAP 3.4
« Valiant/Filter/ToArray.pm ↑ Summary Valiant/Filters.pm »
1 package Valiant::Proxy::Array;
2  
3 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 with 'Valiant::Proxy';
5 sub read_attribute_for_validation {
6 37 ▶ my ($self, $attribute) = @_;
Subroutine read_attribute_for_validation: called CC=4 SCAR=14.0
Pod undocumented
7 #my $index = $attribute->[-1];
8 37 my (@index) = $attribute=~m/\[(\d+)\]/g;
9 37 ▶ if( @index && $index[-1] =~m/^\d+$/ && defined $self->for->[$index[-1]]) {
Branch: 1 branch
BranchTrueFalseTotal
if (@index and $index[-1] =~ /^\d+$/ and defined $self->for->[$index[-1]]) { } 29 8 37
Condition66%4/6
@index and $index[-1] =~ /^\d+$/ and defined $self->for->[$index[-1]]
!ll&&!rl&&r
8029
@index and $index[-1] =~ /^\d+$/
!ll&&!rl&&r
8029
MC/DC33%1/3
@index and $index[-1] =~ /^\d+$/ and defined $self->for->[$index[-1]]
@index $index[-1] =~ /^\d+$/ defined $self->for->[$index[-1]]
Truth table50%2/4
A and B and C
A= @indexB= $index[-1] =~ /^\d+$/C= defined $self->for->[$index[-1]]
ABCresult
0XX0
10X0
1100
1111
10 29 return $self->for->[$index[-1]];
11 } else {
12 8 return undef; # TODO Might need a flag to allow die here?
13 }
14 }
15  
16 2 1;
17  
18 =head1 NAME
19  
20 Valiant::Proxy::Array - Wrap a hashref in a result object for validation.
21  
22 =head1 SYNOPSIS
23  
24 TBD
25  
26 =head1 DESCRIPTION
27  
28 Allows you to run validations against a HashRef.
29  
30 You probably won't use this directly (although you can) since we have L<Valiant::Class> to
31 encapsulate the most common patterns for this need.
32  
33 =head1 SEE ALSO
34  
35 This does the interface defined by L<Valiant::Result> so see the docs on that.
36
37 Also: L<Valiant>, L<Valiant::Validator>, L<Valiant::Validator::Each>.
38  
39 =head1 AUTHOR
40
41 See L<Valiant>
42  
43 =head1 COPYRIGHT & LICENSE
44
45 See L<Valiant>
46  
47 =cut
« Valiant/Filter/ToArray.pm ↑ Summary Valiant/Filters.pm »