Nested/Filter.pm

filter: Statementstmt 88.5% 31 / 35 Branchbran 37.5% 3 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 80.0% 40 / 50 CC 7 SCAR 17.6
CC
7
Cov
79%
filter
9.3
BEGIN
1.0
BEGIN
1.0
CRAP 5.8
« Nested/Profile/Param/Filter.pm ↑ Summary Nested/Profile/Param.pm »
1 package FormValidator::Nested::Filter;
2 3 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use FormValidator::Nested::ProfileProvider;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Class::Param;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 has 'profile_provider' => (
11 is => 'ro',
12 isa => 'FormValidator::Nested::ProfileProvider',
13 required => 1,
14 handles => [qw/get_profile/],
15 );
16 3 __PACKAGE__->meta->make_immutable;
17  
18 21 ▶sub filter {
Subroutine filter: called CC=7 SCAR=22.3
Pod undocumented
19 21 my $self = shift;
20 21 my $req = shift;
21 21 my $profile_key = shift;
22  
23 21 my $hash = 0;
24 21 ▶ if ( blessed($req) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (builtin::blessed($req)) { } 21 0 21
elsif (ref $req eq 'HASH') { } 0 0 0
25 21 ▶ if ( !$req->can('param') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($req->can("param")) 0 21 21
26 0 croak("req cannot call param method.");
27 }
28 }
29 elsif ( ref $req eq 'HASH' ) {
30 0 $req = Class::Param->new($req);
31 0 $hash = 1;
32 }
33  
34 21 my $profile = $self->get_profile($profile_key);
35  
36 21 foreach my $param ( $profile->get_params ) {
37 121 foreach my $filter ( $param->get_filters ) {
38 121 my $values_ref = $param->get_values($req);
39 121 $filter->process($req, $values_ref);
40 }
41 }
42  
43 21 ▶ if ( $hash ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hash) 0 21 21
44 0 return $req->as_hash;
45 }
46  
47 21 return $req;
48 }
49  
50 3 1;
51 __END__
« Nested/Profile/Param/Filter.pm ↑ Summary Nested/Profile/Param.pm »