| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%2/6
$value =~ /^\d+$/ and $digit =~ /^\d+$/ and $digit > 0
$value =~ /^\d+$/ and $digit =~ /^\d+$/
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
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | $value =~ /^\d+$/ | ||||||||||||||||||||||||||||||||||||||||||
| 25 | and $digit =~ /^\d+$/ | ||||||||||||||||||||||||||||||||||||||||||
| 26 | and $digit > 0 | ||||||||||||||||||||||||||||||||||||||||||
| 27 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | ▶ | if( length $value >= $digit ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||||||||||||||||