FormHandler/Result.pm

filter: Statementstmt 100% 31 / 31 Branchbran 100% 4 / 4 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 5 totaltotal 90.5% 48 / 53 CC 5 SCAR 6.1
CC
5
Cov
100%
validated
3.0
value
2.0
peek
2.0
CRAP 1.8
« FormHandler/TraitFor/Types.pm ↑ Summary FormHandler/I18N.pm »
1 package HTML::FormHandler::Result;
2 # ABSTRACT: form result object
3 147 $HTML::FormHandler::Result::VERSION = '0.410002';
4 147 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 # following is to allow the form to return an empty
6 # hashref when value is undefined, without messing
7 # with the way 'value' works for fields
8 147 with 'HTML::FormHandler::Result::Role';
9 147 with 'HTML::FormHandler::Traits';
10  
11  
12 147 has 'form' => (
13 isa => 'HTML::FormHandler',
14 is => 'ro',
15 weak_ref => 1,
16 # handles => ['render' ]
17 );
18  
19 147 has '_value' => (
20 is => 'ro',
21 writer => '_set_value',
22 reader => '_get_value',
23 clearer => '_clear_value',
24 predicate => 'has_value',
25 );
26  
27 84 ▶sub value { shift->_get_value || {} }
Subroutine value: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
(shift())->_get_value or {} 82 2 84
28  
29 has 'form_errors' => (
30 traits => ['Array'],
31 is => 'rw',
32 isa => 'ArrayRef[Str]',
33 569 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
34 147 handles => {
35 all_form_errors => 'elements',
36 push_form_errors => 'push',
37 num_form_errors => 'count',
38 has_form_errors => 'count',
39 clear_form_errors => 'clear',
40 }
41 );
42  
43 1 ▶sub form_and_field_errors {
Subroutine form_and_field_errors: called CC=1 SCAR=0.0
Pod undocumented
44 1 my $self = shift;
45 1 my @field_errors = map { $_->all_errors } $self->all_error_results;
46 1 my @form_errors = $self->all_form_errors;
47 1 return (@form_errors, @field_errors);
48 }
49  
50 1127 ▶sub validated { !$_[0]->has_error_results && $_[0]->has_input && !$_[0]->has_form_errors }
Subroutine validated: called CC=3 SCAR=11.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
not $_[0]->has_error_results and $_[0]->has_input and not $_[0]->has_form_errors 470 657 1127
Condition100%3/3
not $_[0]->has_error_results and $_[0]->has_input
!ll&&!rl&&r
283374470
MC/DC100%2/2
not $_[0]->has_error_results and $_[0]->has_input
not $_[0]->has_error_results $_[0]->has_input
Truth table100%3/3
not(A) and B
A= not $_[0]->has_error_resultsB= $_[0]->has_input
ABresult
0X0
100
111
51  
52 147 has 'ran_validation' => ( is => 'rw', isa => 'Bool', default => 0 );
53  
54 1 ▶sub fif {
Subroutine fif: called CC=1 SCAR=0.0
Pod undocumented
55 1 my $self = shift;
56 1 $self->form->fields_fif($self);
57 }
58  
59 2 ▶sub peek {
Subroutine peek: called CC=2 SCAR=6.9
Pod undocumented
60 2 my $self = shift;
61 2 my $string = "Form Result " . $self->name . "\n";
62 2 my $indent = ' ';
63 2 foreach my $res ( $self->results ) {
64 6 $string .= $res->peek( $indent );
65 }
66 2 return $string;
67 }
68  
69 147 __PACKAGE__->meta->make_immutable;
70 147 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
71 147 1;
72  
73 __END__
« FormHandler/TraitFor/Types.pm ↑ Summary FormHandler/I18N.pm »