lib/HTML/FormFu/Filter/CompoundJoin.pm

filter: Statementstmt 100% 26 / 26 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 85.3% 35 / 41 SCAR 13.9
CC
4
Cov
91%
filter
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« lib/HTML/FormFu/Constraint/File.pm ↑ Summary lib/HTML/FormFu/Role/Element/NonBlock.pm »
1 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Filter::CompoundJoin;
4 6 $HTML::FormFu::Filter::CompoundJoin::VERSION = '2.06';
5 # ABSTRACT: CompoundJoin filter
6  
7 6 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use MooseX::Attribute::Chained;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 extends 'HTML::FormFu::Filter';
10  
11 6 with 'HTML::FormFu::Role::Filter::Compound';
12  
13 6 ▶use HTML::FormFu::Constants qw( $EMPTY_STR $SPACE );
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 6 has join => ( is => 'rw', traits => ['Chained'] );
16  
17 sub filter {
18 5 ▶ my ( $self, $value ) = @_;
Subroutine filter: called CC=4 SCAR=14.2
Pod undocumented
19  
20 5 ▶ return if !defined $value || $value eq $EMPTY_STR;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value or $value eq $HTML::FormFu::Filter::CompoundJoin::EMPTY_STR 0 5 5
Condition33%1/3
not defined $value or $value eq $HTML::FormFu::Filter::CompoundJoin::EMPTY_STR
l!l&&r!l&&!r
005
MC/DC0%0/2
not defined $value or $value eq $HTML::FormFu::Filter::CompoundJoin::EMPTY_STR
not defined $value $value eq $HTML::FormFu::Filter::CompoundJoin::EMPTY_STR
Truth table33%1/3
not(A) or B
A= not defined $valueB= $value eq $HTML::FormFu::Filter::CompoundJoin::EMPTY_STR
ABresult
1X1
011
000
21  
22 5 ▶ my $join
Branch: 1 branch
BranchTrueFalseTotal
defined $self->join ? : 1 4 5
23 = defined $self->join
24 ? $self->join
25 : $SPACE;
26  
27 5 my @values = $self->_get_values($value);
28  
29 5 @values = grep { $_ ne '' } @values;
30  
31 5 $value = join $join, @values;
32  
33 5 return $value;
34 }
35  
36 6 __PACKAGE__->meta->make_immutable;
37  
38 6 1;
39  
40 __END__
41  
42 =pod
43  
44 =encoding UTF-8
45  
46 =head1 NAME
47  
48 HTML::FormFu::Filter::CompoundJoin - CompoundJoin filter
49  
50 =head1 VERSION
51  
52 version 2.06
53  
54 =head1 SYNOPSIS
55  
56 ---
57 element:
58 - type: Multi
59 name: address
60  
61 elements:
62 - name: number
63 - name: street
64  
65 filter:
66 - type: CompoundJoin
67  
68 # get the compound-value
69  
70 my $address = $form->param_value('address');
71  
72 =head1 DESCRIPTION
73  
74 For use with a L<HTML::FormFu::Element::Multi> group of fields.
75  
76 Joins the input from several fields into a single value.
77  
78 =head1 METHODS
79  
80 =head2 join
81  
82 Arguments: $string
83  
84 Default Value: C<' '>
85  
86 String used to join the individually submitted parts. Defaults to a single
87 space.
88  
89 =head2 field_order
90  
91 Inherited. See L<HTML::FormFu::Filter::_Compound/field_order> for details.
92  
93 ---
94 element:
95 - type: Multi
96 name: address
97  
98 elements:
99 - name: street
100 - name: number
101  
102 filter:
103 - type: CompoundJoin
104 field_order:
105 - number
106 - street
107  
108 =head1 AUTHOR
109  
110 Carl Franks, C<cfranks@cpan.org>
111  
112 =head1 LICENSE
113  
114 This library is free software, you can redistribute it and/or modify it under
115 the same terms as Perl itself.
116  
117 =head1 AUTHOR
118  
119 Carl Franks <cpan@fireartist.com>
120  
121 =head1 COPYRIGHT AND LICENSE
122  
123 This software is copyright (c) 2018 by Carl Franks.
124  
125 This is free software; you can redistribute it and/or modify it under
126 the same terms as the Perl 5 programming language system itself.
127  
128 =cut
« lib/HTML/FormFu/Constraint/File.pm ↑ Summary lib/HTML/FormFu/Role/Element/NonBlock.pm »