lib/HTML/FormFu/Element/Multi.pm

filter: Statementstmt 93.1% 123 / 132 Branchbran 100% 4 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 94.7% 18 / 19 Podpod n/a totaltotal 92.4% 146 / 158 CC 5 SCAR 3.9
CC
5
Cov
93%
_parse_layout_field
3.0
render_data
2.0
get_deflators
2.0
CRAP 1.5
« lib/HTML/FormFu/Plugin/StashValid.pm ↑ Summary lib/HTML/FormFu/Element/Number.pm »
1 57 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Element::Multi;
4 57 $HTML::FormFu::Element::Multi::VERSION = '2.09';
5 # ABSTRACT: Combine multiple fields in a single element
6  
7 57 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 57 ▶use MooseX::Attribute::Chained;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 57 extends 'HTML::FormFu::Element::Block';
10  
11 57 with
12 'HTML::FormFu::Role::Element::Field',
13 'HTML::FormFu::Role::Element::SingleValueField';
14  
15 use HTML::FormFu::Util
16 57 ▶ qw( append_xml_attribute xml_escape process_attrs _parse_args _get_elements _filter_components );
Subroutine BEGIN: called CC=1 SCAR=0.0
17 57 ▶use Clone ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 110 ▶after BUILD => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
20 110 my $self = shift;
21  
22 110 $self->comment_attributes( {} );
23 110 $self->container_attributes( {} );
24 110 $self->label_attributes( {} );
25 110 $self->layout_field_filename('field_layout_multi_field');
26 110 $self->label_tag('label');
27  
28 110 return;
29 57 };
30  
31 611 ▶sub get_fields {
Subroutine get_fields: called CC=1 SCAR=0.0
32 611 my $self = shift;
33 611 my %args = _parse_args(@_);
34  
35 611 my $f = $self->SUPER::get_fields(@_);
36  
37 611 unshift @$f, $self;
38  
39 611 return _get_elements( \%args, $f );
40 }
41  
42 0 ▶sub get_deflators {
Subroutine get_deflators: not called CC=1 SCAR=6.9
43 0 my $self = shift;
44 0 my %args = _parse_args(@_);
45  
46 0 my @x = @{ $self->_deflators };
47  
48 0 push @x, map { @{ $_->get_deflators(@_) } } @{ $self->_elements };
49  
50 0 return _filter_components( \%args, \@x );
51 }
52  
53 12 ▶sub get_filters {
Subroutine get_filters: called CC=1 SCAR=0.0
54 12 my $self = shift;
55 12 my %args = _parse_args(@_);
56  
57 12 my @x = @{ $self->_filters };
58  
59 12 push @x, map { @{ $_->get_filters(@_) } } @{ $self->_elements };
60  
61 12 return _filter_components( \%args, \@x );
62 }
63  
64 12 ▶sub get_constraints {
Subroutine get_constraints: called CC=1 SCAR=0.0
65 12 my $self = shift;
66 12 my %args = _parse_args(@_);
67  
68 12 my @x = @{ $self->_constraints };
69  
70 12 push @x, map { @{ $_->get_constraints(@_) } } @{ $self->_elements };
71  
72 12 return _filter_components( \%args, \@x );
73 }
74  
75 11 ▶sub get_inflators {
Subroutine get_inflators: called CC=1 SCAR=0.0
76 11 my $self = shift;
77 11 my %args = _parse_args(@_);
78  
79 11 my @x = @{ $self->_inflators };
80  
81 11 push @x, map { @{ $_->get_inflators(@_) } } @{ $self->_elements };
82  
83 11 return _filter_components( \%args, \@x );
84 }
85  
86 11 ▶sub get_validators {
Subroutine get_validators: called CC=1 SCAR=0.0
87 11 my $self = shift;
88 11 my %args = _parse_args(@_);
89  
90 11 my @x = @{ $self->_validators };
91  
92 11 push @x, map { @{ $_->get_validators(@_) } } @{ $self->_elements };
93  
94 11 return _filter_components( \%args, \@x );
95 }
96  
97 11 ▶sub get_transformers {
Subroutine get_transformers: called CC=1 SCAR=0.0
98 11 my $self = shift;
99 11 my %args = _parse_args(@_);
100  
101 11 my @x = @{ $self->_transformers };
102  
103 11 push @x, map { @{ $_->get_transformers(@_) } } @{ $self->_elements };
104  
105 11 return _filter_components( \%args, \@x );
106 }
107  
108 322 ▶sub get_errors {
Subroutine get_errors: called CC=2 SCAR=6.9
109 322 my $self = shift;
110 322 my %args = _parse_args(@_);
111  
112 322 my @x = @{ $self->_errors };
113  
114 322 push @x, map { @{ $_->get_errors(@_) } } @{ $self->_elements };
115  
116 322 _filter_components( \%args, \@x );
117  
118 322 ▶ if ( !$args{forced} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args{"forced"}) 233 89 322
119 233 @x = grep { !$_->forced } @x;
120 }
121  
122 322 return \@x;
123 }
124  
125 84 ▶sub clear_errors {
Subroutine clear_errors: called CC=1 SCAR=0.0
126 84 my ($self) = @_;
127  
128 84 $self->_errors( [] );
129  
130 84 map { $_->clear_errors } @{ $self->_elements };
131  
132 84 return;
133 }
134  
135 34 ▶sub render_data {
Subroutine render_data: called CC=2 SCAR=7.0
136 34 my $self = shift;
137  
138 34 my $render = $self->SUPER::render_data(@_);
139  
140 34 ▶ map { delete $_->{container_tag} } @{ $render->{elements} || [] };
Condition50%1/2
$render->{'elements'} || []
l!l
340
MC/DC0%0/1
$render->{'elements'} || []
$render->{'elements'}
Truth table50%1/2
A
A= $render->{'elements'}
Aresult
11
00
141  
142 34 return $render;
143 }
144  
145 89 ▶sub render_data_non_recursive {
Subroutine render_data_non_recursive: called CC=1 SCAR=0.0
146 89 my $self = shift;
147  
148 89 my $render = $self->SUPER::render_data_non_recursive(@_);
149  
150 89 append_xml_attribute( $render->{attributes}, 'class', 'elements' );
151  
152 89 return $render;
153 }
154  
155 74 ▶sub _parse_layout_field {
Subroutine _parse_layout_field: called CC=3 SCAR=11.0
156 74 my ( $self, $render ) = @_;
157  
158 74 my @html = ( sprintf "<span%s>", process_attrs( $render->{attributes} ), );
159  
160 74 for my $elem ( @{ $self->get_elements } ) {
161 221 my $render = $elem->render_data;
162  
163 221 ▶ next if !defined $render;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $render 1 220 221
164  
165 220 $render->{container_tag} = undef;
166  
167 220 push @html,
168 $elem->string(
169 { render_data => $render, layout => $elem->multi_layout } );
170 }
171  
172 74 push @html, "</span>";
173  
174 74 return join "\n", @html;
175 }
176  
177 9 ▶sub clone {
Subroutine clone: called CC=1 SCAR=0.0
178 9 my $self = shift;
179  
180 9 my $clone = $self->SUPER::clone(@_);
181  
182 9 $clone->comment_attributes( Clone::clone( $self->comment_attributes ) );
183 9 $clone->container_attributes( Clone::clone( $self->container_attributes ) );
184 9 $clone->label_attributes( Clone::clone( $self->label_attributes ) );
185  
186 9 return $clone;
187 }
188  
189 57 __PACKAGE__->meta->make_immutable;
190  
191 57 1;
192  
193 __END__
« lib/HTML/FormFu/Plugin/StashValid.pm ↑ Summary lib/HTML/FormFu/Element/Number.pm »