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

filter: Statementstmt 100% 26 / 26 Branchbran 66.6% 4 / 6 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 77.5% 38 / 49 SCAR 18.2
CC
6
Cov
84%
filter
5.6
parse_parameters
2.0
BEGIN
1.0
CRAP 6.1
« blib/lib/DTL/Fast/Tag/Block.pm ↑ Summary blib/lib/DTL/Fast/Tag.pm »
1 package DTL::Fast::Filter::Getdigit;
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{'get_digit'} = __PACKAGE__;
6  
7 #@Override
8 sub parse_parameters
9 {
10 4 ▶ my $self = shift;
Subroutine parse_parameters: called CC=2 SCAR=7.0
Pod undocumented
11 die $self->get_parse_error("no digit number specified")
12 4 ▶ if not scalar @{$self->{'parameter'}};
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @{$self->{"parameter"};} 0 4 4
13 4 $self->{'digit'} = $self->{'parameter'}->[0];
14 4 return $self;
15 }
16  
17 #@Override
18 sub filter
19 {
20 4 ▶ my ($self, $filter_manager, $value, $context) = @_;
Subroutine filter: called CC=5 SCAR=17.3
Pod undocumented
21
22 4 my $digit = $self->{'digit'}->render($context);
23 4 ▶ if(
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^\d+$/ and $digit =~ /^\d+$/ and $digit > 0) 4 0 4
Condition33%2/6
$value =~ /^\d+$/ and $digit =~ /^\d+$/ and $digit > 0
!ll&&!rl&&r
004
$value =~ /^\d+$/ and $digit =~ /^\d+$/
!ll&&!rl&&r
004
MC/DC0%0/3
$value =~ /^\d+$/ and $digit =~ /^\d+$/ and $digit > 0
$value =~ /^\d+$/ $digit =~ /^\d+$/ $digit > 0
Truth table25%1/4
A and B and C
A= $value =~ /^\d+$/B= $digit =~ /^\d+$/C= $digit > 0
ABCresult
0XX0
10X0
1100
1111
24 $value =~ /^\d+$/
25 and $digit =~ /^\d+$/
26 and $digit > 0
27 )
28 {
29 4 ▶ if( length $value >= $digit )
Branch: 1 branch
BranchTrueFalseTotal
if (length $value >= $digit) { } 3 1 4
30 {
31 3 $value = substr $value, -$digit, 1;
32 }
33 else
34 {
35 1 $value = '';
36 }
37 }
38
39 4 return $value;
40 }
41  
42 2 1;
« blib/lib/DTL/Fast/Tag/Block.pm ↑ Summary blib/lib/DTL/Fast/Tag.pm »