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

filter: Statementstmt 100% 27 / 27 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 88.1% 37 / 42 SCAR 13.9
CC
4
Cov
91%
filter
3.1
parse_parameters
2.0
BEGIN
1.0
CRAP 4.0
« blib/lib/DTL/Fast/Filter/Split.pm ↑ Summary blib/lib/DTL/Fast/Tag/Verbatim.pm »
1 package DTL::Fast::Filter::Stringformat;
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{'stringformat'} = __PACKAGE__;
6  
7 2 ▶use DTL::Fast::Variable;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 #@Override
10 sub parse_parameters
11 {
12 3 ▶ my $self = shift;
Subroutine parse_parameters: called CC=2 SCAR=7.0
Pod undocumented
13 die $self->get_parse_error("no format string specified")
14 3 ▶ if not scalar @{$self->{'parameter'}};
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @{$self->{"parameter"};} 0 3 3
15 3 $self->{'format'} = $self->{'parameter'}->[0];
16 3 return $self;
17 }
18  
19 #@Override
20 sub filter
21 {
22 3 ▶ my($self, $filter_manager, $value, $context ) = @_;
Subroutine filter: called CC=3 SCAR=11.3
Pod undocumented
23
24 3 my $format = $self->{'format'}->render($context);
25  
26 3 ▶ die $self->get_render_error($context, 'unable to format string with undef value')
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 3 3
27 if not defined $value;
28  
29 3 ▶ die $self->get_render_error($context, 'unable to format string with undef format')
Branch: 1 branch
BranchTrueFalseTotal
unless defined $format 0 3 3
30 if not defined $format;
31  
32 3 return sprintf '%'.$format, $value;
33 }
34  
35 2 1;
« blib/lib/DTL/Fast/Filter/Split.pm ↑ Summary blib/lib/DTL/Fast/Tag/Verbatim.pm »