| 1 | 3 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 2 | |||||||||||||
| 3 | package HTML::FormFu::Filter::Split; | ||||||||||||
| 4 | 3 | $HTML::FormFu::Filter::Split::VERSION = '2.06'; | |||||||||||
| 5 | # ABSTRACT: filter splitting a singe value into an arrayref | ||||||||||||
| 6 | |||||||||||||
| 7 | 3 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 3 | ▶ | use MooseX::Attribute::Chained; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 3 | extends 'HTML::FormFu::Filter'; | |||||||||||
| 10 | |||||||||||||
| 11 | 3 | has regex => ( is => 'rw', traits => ['Chained'] ); | |||||||||||
| 12 | 3 | has limit => ( is => 'rw', traits => ['Chained'] ); | |||||||||||
| 13 | |||||||||||||
| 14 | sub filter { | ||||||||||||
| 15 | 14 | ▶ | my ( $self, $value ) = @_; | ||||||||||
|
Subroutine
filter: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||
| 16 | |||||||||||||
| 17 | 14 | ▶ | return if !defined $value; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 18 | |||||||||||||
| 19 | 14 | my $regex = $self->regex; | |||||||||||
| 20 | 14 | ▶ | my $limit = $self->limit || 0; | ||||||||||
|
Condition100%2/2
$self->limit || 0
MC/DC100%1/1
$self->limit || 0
$self->limit
Truth table100%2/2
A
A= $self->limit
| |||||||||||||
| 21 | |||||||||||||
| 22 | 14 | ▶ | $regex = '' if !defined $regex; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 23 | |||||||||||||
| 24 | 14 | my @values = split /$regex/, $value, $limit; | |||||||||||
| 25 | |||||||||||||
| 26 | 14 | ▶ | return if !@values; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 27 | |||||||||||||
| 28 | 6 | return \@values; | |||||||||||
| 29 | } | ||||||||||||
| 30 | |||||||||||||
| 31 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 32 | |||||||||||||
| 33 | 3 | 1; | |||||||||||
| 34 | |||||||||||||
| 35 | __END__ | ||||||||||||
| 36 | |||||||||||||
| 37 | =pod | ||||||||||||
| 38 | |||||||||||||
| 39 | =encoding UTF-8 | ||||||||||||
| 40 | |||||||||||||
| 41 | =head1 NAME | ||||||||||||
| 42 | |||||||||||||
| 43 | HTML::FormFu::Filter::Split - filter splitting a singe value into an arrayref | ||||||||||||
| 44 | |||||||||||||
| 45 | =head1 VERSION | ||||||||||||
| 46 | |||||||||||||
| 47 | version 2.06 | ||||||||||||
| 48 | |||||||||||||
| 49 | =head1 SYNOPSIS | ||||||||||||
| 50 | |||||||||||||
| 51 | type: Split | ||||||||||||
| 52 | regex: '-' | ||||||||||||
| 53 | |||||||||||||
| 54 | =head1 DESCRIPTION | ||||||||||||
| 55 | |||||||||||||
| 56 | Split a single input value into an arrayref of values. | ||||||||||||
| 57 | |||||||||||||
| 58 | =head1 METHODS | ||||||||||||
| 59 | |||||||||||||
| 60 | =head2 regex | ||||||||||||
| 61 | |||||||||||||
| 62 | A regex object or string to be passed as the C<PATTERN> argument to C<split>. | ||||||||||||
| 63 | |||||||||||||
| 64 | Default Value: '' (empty string) | ||||||||||||
| 65 | |||||||||||||
| 66 | =head2 limit | ||||||||||||
| 67 | |||||||||||||
| 68 | A number passed as the C<LIMIT> argument to C<split>. | ||||||||||||
| 69 | |||||||||||||
| 70 | Default Value: 0 | ||||||||||||
| 71 | |||||||||||||
| 72 | =head1 AUTHOR | ||||||||||||
| 73 | |||||||||||||
| 74 | Carl Franks, C<cfranks@cpan.org> | ||||||||||||
| 75 | |||||||||||||
| 76 | =head1 LICENSE | ||||||||||||
| 77 | |||||||||||||
| 78 | This library is free software, you can redistribute it and/or modify it under | ||||||||||||
| 79 | the same terms as Perl itself. | ||||||||||||
| 80 | |||||||||||||
| 81 | =head1 AUTHOR | ||||||||||||
| 82 | |||||||||||||
| 83 | Carl Franks <cpan@fireartist.com> | ||||||||||||
| 84 | |||||||||||||
| 85 | =head1 COPYRIGHT AND LICENSE | ||||||||||||
| 86 | |||||||||||||
| 87 | This software is copyright (c) 2018 by Carl Franks. | ||||||||||||
| 88 | |||||||||||||
| 89 | This is free software; you can redistribute it and/or modify it under | ||||||||||||
| 90 | the same terms as the Perl 5 programming language system itself. | ||||||||||||
| 91 | |||||||||||||
| 92 | =cut | ||||||||||||