blib/lib/DTL/Fast/Filter/Split.pm

filter: Statementstmt 100% 24 / 24 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 84.6% 33 / 39 SCAR 13.9
CC
4
Cov
90%
filter
3.1
parse_parameters
2.0
BEGIN
1.0
CRAP 4.0
« blib/lib/DTL/Fast/Filter/Center.pm ↑ Summary blib/lib/DTL/Fast/Filter/Stringformat.pm »
1 package DTL::Fast::Filter::Split;
2 2 ▶use strict; use utf8; use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use parent 'DTL::Fast::Filter';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 $DTL::Fast::FILTER_HANDLERS{'split'} = __PACKAGE__;
6  
7 #@Override
8 sub parse_parameters
9 {
10 1 ▶ my $self = shift;
Subroutine parse_parameters: called CC=2 SCAR=7.0
Pod undocumented
11 die $self->get_parse_error("no split pattern specified")
12 1 ▶ if not scalar @{$self->{'parameter'}};
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @{$self->{"parameter"};} 0 1 1
13 1 $self->{'pattern'} = $self->{'parameter'}->[0];
14 1 return $self;
15 }
16  
17 #@Override
18 sub filter
19 {
20 1 ▶ my($self, $filter_manager, $value, $context ) = @_;
Subroutine filter: called CC=3 SCAR=11.3
Pod undocumented
21
22 1 my $pattern = $self->{'pattern'}->render($context);
23
24 1 ▶ die $self->get_render_error("splitting pattern must be defined and not empty")
Branch: 1 branch
BranchTrueFalseTotal
unless $pattern 0 1 1
25 if not $pattern;
26
27 1 ▶ $value = [split /$pattern/si, $value // ''];
Condition50%1/2
$value // ""
l!l
10
MC/DC0%0/1
$value // ""
$value
Truth table50%1/2
A
A= $value
Aresult
11
00
28
29 1 return $value;
30 }
31  
32 2 1;
« blib/lib/DTL/Fast/Filter/Center.pm ↑ Summary blib/lib/DTL/Fast/Filter/Stringformat.pm »