SyForm/Values.pm

filter: Statementstmt 96.7% 30 / 31 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 4 totaltotal 85.4% 41 / 48 CC 7 SCAR 9.6
CC
7
Cov
95%
_build_results
4.0
create_results
3.0
as_hashref
2.0
CRAP 2.6
« SyForm/FieldRole/Process.pm ↑ Summary SyForm/FieldRole/Default.pm »
1 package SyForm::Values;
2 6 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 $SyForm::Values::AUTHORITY = 'cpan:GETTY';
4 }
5 # ABSTRACT: Values given of the fields through the process args
6 6 $SyForm::Values::VERSION = '0.103';
7 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 6 with qw(
10 MooX::Traits
11 SyForm::ValuesRole::Verify
12 );
13  
14 6 has syform => (
15 is => 'ro',
16 required => 1,
17 handles => [qw(
18 field
19 field_names
20 )],
21 );
22  
23 6 has values => (
24 is => 'ro',
25 required => 1,
26 );
27 0 ▶sub as_hashref { $_[0]->values }
Subroutine as_hashref: not called CC=1 SCAR=6.9
Pod undocumented
28  
29 6 has results => (
30 is => 'lazy',
31 );
32  
33 11 ▶sub _build_results {
Subroutine _build_results: called CC=4 SCAR=13.9
34 11 my ( $self ) = @_;
35 11 my $results;
36 11 eval {
37 11 my %results_args;
38 11 for my $field ($self->syform->fields->Values) {
39 38 my %field_results_args = $field->results_args_by_values($self);
40 38 $results_args{$_} = $field_results_args{$_} for keys %field_results_args;
41 }
42 11 $results = $self->create_results( %results_args );
43 };
44 11 ▶ SyForm->throw( UnknownErrorOnValuesBuildResults => $self, $@ ) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 11 11
45 11 return $results;
46 }
47  
48 11 ▶sub create_results {
Subroutine create_results: called CC=3 SCAR=11.0
Pod undocumented
49 11 my ( $self, %args ) = @_;
50 11 my %results;
51 11 for my $field ($self->syform->fields->Values) {
52 38 my $name = $field->name;
53 38 ▶ $results{$name} = delete $args{$name} if exists $args{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{$name} 19 19 38
54 }
55 11 return $self->syform->loaded_results_class->new({
56 values => $self,
57 results => { %results },
58 %args
59 });
60 }
61  
62 38 ▶sub get_value {
Subroutine get_value: called CC=1 SCAR=0.0
Pod undocumented
63 38 my ( $self, $name ) = @_;
64 38 return $self->values->{$name};
65 }
66  
67 66 ▶sub has_value {
Subroutine has_value: called CC=2 SCAR=6.9
Pod undocumented
68 66 my ( $self, $name ) = @_;
69 66 ▶ return exists($self->values->{$name}) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $self->values->{$name} ? : 38 28 66
70 }
71  
72 6 1;
73  
74 __END__
« SyForm/FieldRole/Process.pm ↑ Summary SyForm/FieldRole/Default.pm »