FormHandler/Field/SelectCSV.pm

filter: Statementstmt 92.3% 24 / 26 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 25.0% 1 / 4 totaltotal 81.4% 35 / 43 CC 4 SCAR 5.0
CC
4
Cov
84%
selectcsv_inflate_default
2.1
selectcsv_deflate_value
2.1
fif
2.0
CRAP 1.6
« FormHandler/I18N.pm ↑ Summary FormHandler/Widget/Theme/Bootstrap3.pm »
1 package HTML::FormHandler::Field::SelectCSV;
2 # ABSTRACT: Multiple select field from CSV value
3 1 $HTML::FormHandler::Field::SelectCSV::VERSION = '0.410000';
4 1 ▶use HTML::FormHandler::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 extends 'HTML::FormHandler::Field::Select';
6  
7  
8 2 ▶has '+inflate_default_method' => ( default => sub { \&selectcsv_inflate_default } );
Subroutine __ANON__: called CC=1 SCAR=0.0
9 2 ▶has '+deflate_value_method' => ( default => sub { \&selectcsv_deflate_value } );
Subroutine __ANON__: called CC=1 SCAR=0.0
10 1 has '+multiple' => ( default => 1 );
11 1 ▶sub build_value_when_empty { undef }
Subroutine build_value_when_empty: called CC=1 SCAR=0.0
Pod undocumented
12  
13 sub selectcsv_inflate_default {
14 3 ▶ my ( $self, $value ) = @_;
Subroutine selectcsv_inflate_default: called CC=2 SCAR=7.4
Pod undocumented
15 3 ▶ if( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 3 0 3
16 3 my @values = split (/,/, $value);
17 3 return @values;
18 }
19 0 return;
20 }
21  
22 sub selectcsv_deflate_value {
23 1 ▶ my ( $self, $value ) = @_;
Subroutine selectcsv_deflate_value: called CC=2 SCAR=7.4
Pod undocumented
24 1 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 1 0 1
25 1 my $str = join( ',', sort @$value );
26 1 return $str;
27 }
28 0 return;
29 }
30  
31 sub fif {
32 12 ▶ my $self = shift;
Subroutine fif: called CC=2 SCAR=7.0
Pod documented
33 12 my $fif = $self->next::method;
34 12 ▶ $fif = [] if $fif eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $fif eq "" 0 12 12
35 12 return $fif;
36 }
37  
38 1 1;
39  
40 __END__
41  
42 =pod
43  
44 =encoding UTF-8
45  
46 =head1 NAME
47  
48 HTML::FormHandler::Field::SelectCSV - Multiple select field from CSV value
49  
50 =head1 VERSION
51  
52 version 0.410000
53  
54 =head1 SYNOPSIS
55  
56 A multiple select field for comma-separated values in the database.
57 It expects database values like: '1,5,7'. The string will be inflated
58 into an arrayref for validation and form filling, and will be deflated
59 into a comma-separated string in the output value.
60  
61 This field is useful for MySQL 'set' columns.
62  
63 =head1 NAME
64  
65 HTML::FormHandler::Field::SelectCSV
66  
67 =head1 AUTHOR
68  
69 FormHandler Contributors - see HTML::FormHandler
70  
71 =head1 COPYRIGHT AND LICENSE
72  
73 This software is copyright (c) 2017 by Gerda Shank.
74  
75 This is free software; you can redistribute it and/or modify it under
76 the same terms as the Perl 5 programming language system itself.
77  
78 =cut
« FormHandler/I18N.pm ↑ Summary FormHandler/Widget/Theme/Bootstrap3.pm »