lib/HTML/FormFu/Constraint/AutoSet.pm

filter: Statementstmt 100% 23 / 23 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 83.7% 31 / 37 SCAR 13.9
CC
4
Cov
90%
_parse_value
4.2
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« lib/HTML/FormFu/Constraint/JSON.pm ↑ Summary lib/HTML/FormFu/Filter/CompoundSprintf.pm »
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Constraint::AutoSet;
4 3 $HTML::FormFu::Constraint::AutoSet::VERSION = '2.06';
5 # ABSTRACT: Set Constraint for Selects / Radiogroups / Checkboxgroups
6  
7 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 extends 'HTML::FormFu::Constraint::Set';
9  
10 sub process {
11 7 ▶ my $self = shift;
Subroutine process: called CC=1 SCAR=0.0
Pod undocumented
12  
13 7 my @set = map { _parse_value($_) } @{ $self->parent->_options };
14  
15 7 $self->set( \@set );
16  
17 7 return $self->SUPER::process(@_);
18 }
19  
20 sub _parse_value {
21 23 ▶ my ($item) = @_;
Subroutine _parse_value: called CC=4 SCAR=14.2
22  
23 23 ▶ if ( exists $item->{group} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $item->{'group'}) { } 2 21 23
24 2 return map { _parse_value($_) } @{ $item->{group} };
25 }
26 else {
27 # disabled attributes should be ignored
28 21 ▶ return if ( $item->{attributes} and $item->{attributes}->{disabled} );
Branch: 1 branch
BranchTrueFalseTotal
if $item->{"attributes"} and $item->{"attributes"}{"disabled"} 0 21 21
Condition33%1/3
$item->{"attributes"} and $item->{"attributes"}{"disabled"}
!ll&&!rl&&r
0210
MC/DC0%0/2
$item->{"attributes"} and $item->{"attributes"}{"disabled"}
$item->{"attributes"} $item->{"attributes"}{"disabled"}
Truth table33%1/3
A and B
A= $item->{"attributes"}B= $item->{"attributes"}{"disabled"}
ABresult
0X0
100
111
29  
30 # anything else is fine
31 21 return $item->{value};
32 }
33 }
34  
35 3 __PACKAGE__->meta->make_immutable;
36  
37 3 1;
38  
39 __END__
40  
41 =pod
42  
43 =encoding UTF-8
44  
45 =head1 NAME
46  
47 HTML::FormFu::Constraint::AutoSet - Set Constraint for Selects / Radiogroups / Checkboxgroups
48  
49 =head1 VERSION
50  
51 version 2.06
52  
53 =head1 DESCRIPTION
54  
55 For use with L<HTML::FormFu::Element::Radiogroup>,
56 L<HTML::FormFu::Element::Select> and L<HTML::FormFu::Element::Checkboxgroup>
57 fields.
58  
59 Ensures that the input value is one of the pre-defined element options.
60  
61 =head1 SEE ALSO
62  
63 Is a sub-class of, and inherits methods from L<HTML::FormFu::Constraint::Set>
64  
65 L<HTML::FormFu>
66  
67 =head1 AUTHOR
68  
69 Carl Franks C<cfranks@cpan.org>
70  
71 =head1 LICENSE
72  
73 This library is free software, you can redistribute it and/or modify it under
74 the same terms as Perl itself.
75  
76 =head1 AUTHOR
77  
78 Carl Franks <cpan@fireartist.com>
79  
80 =head1 COPYRIGHT AND LICENSE
81  
82 This software is copyright (c) 2018 by Carl Franks.
83  
84 This is free software; you can redistribute it and/or modify it under
85 the same terms as the Perl 5 programming language system itself.
86  
87 =cut
« lib/HTML/FormFu/Constraint/JSON.pm ↑ Summary lib/HTML/FormFu/Filter/CompoundSprintf.pm »