Declare/Action/CatchValidationError.pm

filter: Statementstmt 55.3% 31 / 56 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 12 / 15 Podpod n/a totaltotal 47.7% 43 / 90 CC 10 SCAR 31.6
CC
10
Cov
42%
__ANON__
65.1
__ANON__
10.2
__ANON__
1.4
CRAP 23.6
« Declare/Keyword/Action.pm ↑ Summary Declare/Dispatching/ChainTypeSensitivity.pm »
1 15 ▶use MooseX::Declare;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 15 ▶role CatalystX::Declare::Action::CatchValidationError {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=2.1
4  
5 15 ▶ use MooseX::Types::Moose qw( ArrayRef Str HashRef );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 15 ▶ use aliased 'Moose::Meta::TypeConstraint';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 15 has method_type_constraint => (
9 is => 'rw',
10 isa => TypeConstraint,
11 handles => {
12 _check_action_arguments => 'check',
13 },
14 );
15  
16 15 has method_named_params => (
17 is => 'rw',
18 isa => ArrayRef[Str],
19 );
20  
21 15 has method_named_type_constraint => (
22 is => 'rw',
23 isa => HashRef[TypeConstraint],
24 );
25  
26 15 has controller_instance => (
27 is => 'rw',
28 isa => 'Catalyst::Controller',
29 weak_ref => 1,
30 );
31  
32 0 ▶ method extract_named_params (Object $ctx) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=8 SCAR=41.8
33  
34 0 my %extracted;
35 0 my $tcs = $self->method_named_type_constraint;
36
37 0 ▶ if (my $named = $self->method_named_params) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $named = $self->method_named_params) 0 0 0
38  
39 0 for my $key (@$named) {
40  
41 0 my $value = $ctx->request->params->{ $key };
42 0 my $tc = $tcs->{ $key };
43
44 0 ▶ if ($tc and $tc->is_subtype_of(ArrayRef)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tc and $tc->is_subtype_of(ArrayRef())) { } 0 0 0
Condition0%0/3
$tc and $tc->is_subtype_of(ArrayRef())
!ll&&!rl&&r
000
MC/DC0%0/2
$tc and $tc->is_subtype_of(ArrayRef())
$tc $tc->is_subtype_of(ArrayRef())
Truth table0%0/3
A and B
A= $tcB= $tc->is_subtype_of(ArrayRef())
ABresult
0X0
100
111
45  
46 $value = []
47 0 ▶ unless exists $ctx->request->params->{ $key };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ctx->request->params->{$key} 0 0 0
48  
49 0 ▶ $value = [$value]
Branch: 1 branch
BranchTrueFalseTotal
unless is_ArrayRef($value) 0 0 0
50 unless is_ArrayRef $value;
51 }
52 else {
53
54 0 ▶ next unless exists $ctx->request->params->{ $key };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ctx->request->params->{$key} 0 0 0
55 }
56  
57 0 $extracted{ $key } = $value;
58 }
59 }
60  
61 0 return \%extracted;
62 15 }
63  
64 0 ▶ around execute (Object $ctrl, Object $ctx, @rest) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=3.5
65  
66 0 return $self->$orig($ctrl, $ctx, @rest, %{ $self->extract_named_params($ctx) });
67 15 }
68  
69 0 ▶ around match (Object $ctx) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=3 SCAR=23.2
70  
71 return
72 0 ▶ unless $self->$orig($ctx);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->$orig($ctx) 0 0 0
73 0 ▶ return 1
Branch: 1 branch
BranchTrueFalseTotal
unless $self->method_type_constraint 0 0 0
74 unless $self->method_type_constraint;
75  
76 0 my @args = ($self->controller_instance, $ctx, @{ $ctx->req->args });
77 0 my $tc = $self->method_type_constraint;
78 0 my $np = $self->extract_named_params($ctx);
79 0 my $ret = $tc->_type_constraint->check([\@args, $np]);
80  
81 0 return $ret;
82 15 }
83 15 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
« Declare/Keyword/Action.pm ↑ Summary Declare/Dispatching/ChainTypeSensitivity.pm »