Valiant/Filter/Collection.pm

filter: Statementstmt 100% 14 / 14 Branchbran 100% 2 / 2 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 2 / 2 Podpod 0.0% 0 / 1 totaltotal 80.0% 20 / 25 CC 5 SCAR 14.8
CC
5
Cov
90%
filter
5.1
BEGIN
1.0
CRAP 4.4
« Valiant/Util/Exception.pm ↑ Summary Valiant/Validator/Array.pm »
1 package Valiant::Filter::Collection;
2  
3 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 with 'Valiant::Filter';
6  
7 2 has filters => (is=>'ro', required=>1);
8  
9 5 ▶sub filter {
Subroutine filter: called CC=5 SCAR=16.2
Pod undocumented
10 5 my ($self, $class, $fields) = @_;
11 5 foreach my $filter (@{ $self->filters }) {
12 5 ▶ if( (ref($filter)||'') eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $filter || '') eq 'ARRAY') { } 2 3 5
Condition50%1/2
ref $filter || ''
l!l
50
MC/DC0%0/1
ref $filter || ''
ref $filter
Truth table50%1/2
A
A= ref $filter
Aresult
11
00
13 2 ▶ $fields = $filter->[0]->($class, $fields, +{ %{$filter->[1]||+{}} });
Condition50%1/2
$filter->[1] || {}
l!l
20
MC/DC0%0/1
$filter->[1] || {}
$filter->[1]
Truth table50%1/2
A
A= $filter->[1]
Aresult
11
00
14 } else {
15 3 $fields = $filter->filter($class, $fields);
16 }
17 }
18 5 return $fields;
19 }
20  
21 2 1;
22  
23 =head1 NAME
24  
25 Valiant::Validator::Collection - A filter that contains and runs other filters
26  
27 =head1 SYNOPSIS
28  
29 NA
30  
31 =head1 DESCRIPTION
32  
33 This is used internally by L<Valiant> and I can't imagine a good use for it elsewhere
34 so the documentation here is light. There's no reason to NOT use it if for some
35 reason a good use comes to mind (I don't plan to change this so you can consider it
36 public API but just perhaps tricky bits for very advanced use cases).
37  
38 I guess it could be used to make very complicated nested filters. I'm not going
39 to show you how to do that since I think only people that can figure it out should
40 be allowed. If you think I'm wrong ping me on IRC and submit a doc patch.
41  
42 =head1 SEE ALSO
43
44 L<Valiant>, L<Valiant::Filter>, L<Valiant::Filter::Each>.
45  
46 =head1 AUTHOR
47
48 See L<Valiant>
49
50 =head1 COPYRIGHT & LICENSE
51
52 See L<Valiant>
53  
54 =cut
« Valiant/Util/Exception.pm ↑ Summary Valiant/Validator/Array.pm »