Catalyst/Controller/HTML/FormFu/ActionBase/Form.pm

filter: Statementstmt 92.5% 75 / 81 Branchbran 87.5% 14 / 16 Conditioncond 81.8% 27 / 33 MC/DCmcdc 72.2% 13 / 18 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 87.7% 136 / 155 CC 20 SCAR 28.2
CC
20
Cov
89%
dispatch
20.7
BEGIN
1.0
BEGIN
1.0
CRAP 16.8
↑ Summary Catalyst/Controller/HTML/FormFu/Action/MultiFormConfig.pm »
1 package Catalyst::Controller::HTML::FormFu::ActionBase::Form;
2  
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 9 our $VERSION = '2.04'; # VERSION
6 9 our $AUTHORITY = 'cpan:NIGELM'; # AUTHORITY
7  
8 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 9 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 9 ▶BEGIN { extends 'Catalyst::Action'; }
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 54 ▶sub _form_action_regex {
Subroutine _form_action_regex: called CC=1 SCAR=0.0
15 54 return qr/_FORM_(RENDER|(NOT_)?(VALID|COMPLETE|SUBMITTED))\z/;
16 }
17  
18 40 ▶sub dispatch {
Subroutine dispatch: called CC=20 SCAR=30.3
Pod documented
19 40 my $self = shift;
20 40 my ($c) = @_;
21  
22 40 $self->next::method(@_);
23  
24 40 my $controller = $c->component( $self->class );
25 40 my $config = $controller->_html_formfu_config;
26  
27 40 my $multi = $c->stash->{ $config->{multiform_stash} };
28 40 my $form = $c->stash->{ $config->{form_stash} };
29  
30 40 my $run_form_render_action = 1;
31  
32 # _FORM_COMPLETE
33  
34 40 my $complete_method = $self->name . "_FORM_COMPLETE";
35  
36 40 ▶ if ( defined $multi
Branch: 1 branch
BranchTrueFalseTotal
if (defined $multi and my $code = $controller->can($complete_method) and $multi->complete) 2 38 40
Condition83%5/6
defined $multi and my $code = $controller->can($complete_method) and $multi->complete
!ll&&!rl&&r
3442
defined $multi and my $code = $controller->can($complete_method)
!ll&&!rl&&r
3406
MC/DC66%2/3
defined $multi and my $code = $controller->can($complete_method) and $multi->complete
defined $multi my $code = $controller->can($complete_method) $multi->complete
Truth table75%3/4
A and B and C
A= defined $multiB= my $code = $controller->can($complete_method)C= $multi->complete
ABCresult
0XX0
10X0
1100
1111
37 && ( my $code = $controller->can($complete_method) )
38 && $multi->complete ) {
39 2 my @reverse = split /\//, $self->reverse;
40 2 $reverse[-1] = $complete_method;
41 2 local $self->{reverse} = join '/', @reverse;
42 2 local $self->{code} = $code;
43  
44 2 $run_form_render_action = 0;
45  
46 2 $c->execute( $self->class, $self, @{ $c->req->args } );
47 }
48  
49 # _FORM_SUBMITTED
50  
51 40 my $submitted_method = $self->name . "_FORM_SUBMITTED";
52  
53 40 ▶ if ( ( my $code = $controller->can($submitted_method) )
Branch: 1 branch
BranchTrueFalseTotal
if (my $code = $controller->can($submitted_method) and $form->submitted) 3 37 40
Condition100%3/3
my $code = $controller->can($submitted_method) and $form->submitted
!ll&&!rl&&r
3523
MC/DC100%2/2
my $code = $controller->can($submitted_method) and $form->submitted
my $code = $controller->can($submitted_method) $form->submitted
Truth table100%3/3
A and B
A= my $code = $controller->can($submitted_method)B= $form->submitted
ABresult
0X0
100
111
54 && $form->submitted ) {
55 3 my @reverse = split /\//, $self->reverse;
56 3 $reverse[-1] = $submitted_method;
57 3 local $self->{reverse} = join '/', @reverse;
58 3 local $self->{code} = $code;
59  
60 3 $c->execute( $self->class, $self, @{ $c->req->args } );
61 }
62  
63 # _FORM_VALID
64  
65 40 my $valid_method = $self->name . "_FORM_VALID";
66  
67 40 ▶ if ( ( my $code = $controller->can($valid_method) )
Branch: 1 branch
BranchTrueFalseTotal
if (my $code = $controller->can($valid_method) and $form->submitted_and_valid) 1 39 40
Condition100%3/3
my $code = $controller->can($valid_method) and $form->submitted_and_valid
!ll&&!rl&&r
3541
MC/DC100%2/2
my $code = $controller->can($valid_method) and $form->submitted_and_valid
my $code = $controller->can($valid_method) $form->submitted_and_valid
Truth table100%3/3
A and B
A= my $code = $controller->can($valid_method)B= $form->submitted_and_valid
ABresult
0X0
100
111
68 && $form->submitted_and_valid ) {
69 1 my @reverse = split /\//, $self->reverse;
70 1 $reverse[-1] = $valid_method;
71 1 local $self->{reverse} = join '/', @reverse;
72 1 local $self->{code} = $code;
73  
74 1 ▶ $run_form_render_action = 0
Branch: 1 branch
BranchTrueFalseTotal
unless defined $multi 1 0 1
75 if !defined $multi;
76  
77 1 $c->execute( $self->class, $self, @{ $c->req->args } );
78 }
79  
80 # _FORM_NOT_COMPLETE
81  
82 40 my $not_complete_method = $self->name . "_FORM_NOT_COMPLETE";
83  
84 40 ▶ if ( defined $multi
Branch: 1 branch
BranchTrueFalseTotal
if (defined $multi and my $code = $controller->can($not_complete_method) and $form->submitted and not $multi->complete) 0 40 40
Condition44%4/9
defined $multi and my $code = $controller->can($not_complete_method) and $form->submitted and not $multi->complete
!ll&&!rl&&r
4000
defined $multi and my $code = $controller->can($not_complete_method) and $form->submitted
!ll&&!rl&&r
4000
defined $multi and my $code = $controller->can($not_complete_method)
!ll&&!rl&&r
3460
MC/DC0%0/4
defined $multi and my $code = $controller->can($not_complete_method) and $form->submitted and not $multi->complete
defined $multi my $code = $controller->can($not_complete_method) $form->submitted not $multi->complete
Truth table40%2/5
A and B and C and not(D)
A= defined $multiB= my $code = $controller->can($not_complete_method)C= $form->submittedD= not $multi->complete
ABCDresult
0XXX0
10XX0
110X0
11100
11111
85 && ( my $code = $controller->can($not_complete_method) )
86 && $form->submitted
87 && !$multi->complete ) {
88 0 my @reverse = split /\//, $self->reverse;
89 0 $reverse[-1] = $not_complete_method;
90 0 local $self->{reverse} = join '/', @reverse;
91 0 local $self->{code} = $code;
92  
93 0 $c->execute( $self->class, $self, @{ $c->req->args } );
94 }
95  
96 # _FORM_NOT_VALID
97  
98 40 my $not_valid_method = $self->name . "_FORM_NOT_VALID";
99  
100 40 ▶ if ( ( my $code = $controller->can($not_valid_method) )
Branch: 1 branch
BranchTrueFalseTotal
if (my $code = $controller->can($not_valid_method) and $form->submitted and $form->has_errors) 2 38 40
Condition100%6/6
my $code = $controller->can($not_valid_method) and $form->submitted and $form->has_errors
!ll&&!rl&&r
3712
my $code = $controller->can($not_valid_method) and $form->submitted
!ll&&!rl&&r
3523
MC/DC100%3/3
my $code = $controller->can($not_valid_method) and $form->submitted and $form->has_errors
my $code = $controller->can($not_valid_method) $form->submitted $form->has_errors
Truth table100%4/4
A and B and C
A= my $code = $controller->can($not_valid_method)B= $form->submittedC= $form->has_errors
ABCresult
0XX0
10X0
1100
1111
101 && $form->submitted
102 && $form->has_errors ) {
103 2 my @reverse = split /\//, $self->reverse;
104 2 $reverse[-1] = $not_valid_method;
105 2 local $self->{reverse} = join '/', @reverse;
106 2 local $self->{code} = $code;
107  
108 2 $c->execute( $self->class, $self, @{ $c->req->args } );
109 }
110  
111 # _FORM_NOT_SUBMITTED
112  
113 40 my $not_submitted_method = $self->name . "_FORM_NOT_SUBMITTED";
114  
115 40 ▶ if ( ( my $code = $controller->can($not_submitted_method) )
Branch: 1 branch
BranchTrueFalseTotal
if (my $code = $controller->can($not_submitted_method) and not $form->submitted) 2 38 40
Condition100%3/3
my $code = $controller->can($not_submitted_method) and not $form->submitted
!ll&&!rl&&r
3532
MC/DC100%2/2
my $code = $controller->can($not_submitted_method) and not $form->submitted
my $code = $controller->can($not_submitted_method) not $form->submitted
Truth table100%3/3
A and not(B)
A= my $code = $controller->can($not_submitted_method)B= not $form->submitted
ABresult
0X0
100
111
116 && !$form->submitted ) {
117 2 my @reverse = split /\//, $self->reverse;
118 2 $reverse[-1] = $not_submitted_method;
119 2 local $self->{reverse} = join '/', @reverse;
120 2 local $self->{code} = $code;
121  
122 2 $c->execute( $self->class, $self, @{ $c->req->args } );
123 }
124  
125 # _RENDER
126  
127 40 my $render_method = $self->name . "_FORM_RENDER";
128  
129 40 ▶ if ( $run_form_render_action
Branch: 1 branch
BranchTrueFalseTotal
if ($run_form_render_action and my $code = $controller->can($render_method)) 4 36 40
Condition100%3/3
$run_form_render_action and my $code = $controller->can($render_method)
!ll&&!rl&&r
3334
MC/DC100%2/2
$run_form_render_action and my $code = $controller->can($render_method)
$run_form_render_action my $code = $controller->can($render_method)
Truth table100%3/3
A and B
A= $run_form_render_actionB= my $code = $controller->can($render_method)
ABresult
0X0
100
111
130 && ( my $code = $controller->can($render_method) ) ) {
131 4 my @reverse = split /\//, $self->reverse;
132 4 $reverse[-1] = $render_method;
133 4 local $self->{reverse} = join '/', @reverse;
134 4 local $self->{code} = $code;
135  
136 4 $c->execute( $self->class, $self, @{ $c->req->args } );
137 }
138  
139 40 return;
140 }
141  
142 9 1;
143  
144 __END__
↑ Summary Catalyst/Controller/HTML/FormFu/Action/MultiFormConfig.pm »