| 1 | package DTL::Fast::Filter::Ru::Pluralize; | ||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | 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 | 1 | ▶ | use parent 'DTL::Fast::Filter::Pluralize'; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||
| 5 | 1 | $DTL::Fast::FILTER_HANDLERS{'pluralize'} = __PACKAGE__; | |||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||
| 7 | #@Override | ||||||||||||||||||||||||||||||||||||
| 8 | sub parse_parameters | ||||||||||||||||||||||||||||||||||||
| 9 | { | ||||||||||||||||||||||||||||||||||||
| 10 | 11 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||
|
Subroutine
parse_parameters: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 11 | 2 | push @{$self->{'parameter'}}, DTL::Fast::Variable->new('""') # specify suffix for one, two and five | |||||||||||||||||||||||||||||||||||
| 12 | 11 | ▶ | if not scalar @{$self->{'parameter'}}; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 13 | 11 | $self->{'suffix'} = $self->{'parameter'}->[0]; | |||||||||||||||||||||||||||||||||||
| 14 | 11 | return $self; | |||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||
| 17 | sub pluralize | ||||||||||||||||||||||||||||||||||||
| 18 | { | ||||||||||||||||||||||||||||||||||||
| 19 | 11 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||
|
Subroutine
pluralize: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 20 | 11 | my $value = shift; | |||||||||||||||||||||||||||||||||||
| 21 | 11 | my $suffix = shift; | |||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||
| 23 | 11 | ▶ | my $suffix_one = shift @$suffix // ''; | ||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift @$suffix // ""
MC/DC100%1/1
shift @$suffix // ""
shift @$suffix
Truth table100%2/2
A
A= shift @$suffix
| |||||||||||||||||||||||||||||||||||||
| 24 | 11 | ▶ | my $suffix_two = shift @$suffix // ''; | ||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift @$suffix // ""
MC/DC100%1/1
shift @$suffix // ""
shift @$suffix
Truth table100%2/2
A
A= shift @$suffix
| |||||||||||||||||||||||||||||||||||||
| 25 | 11 | ▶ | my $suffix_five = shift @$suffix // $suffix_two; | ||||||||||||||||||||||||||||||||||
|
Condition100%3/3
shift @$suffix // $suffix_two
MC/DC100%2/2
shift @$suffix // $suffix_two
shift @$suffix
$suffix_two
Truth table100%3/3
A // B
A= shift @$suffixB= $suffix_two
| |||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||
| 27 | 11 | my $last_digit = substr int($value), -1; | |||||||||||||||||||||||||||||||||||
| 28 | 11 | my $amount = abs $value; | |||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||
| 30 | 11 | ▶ | if( $amount >= 10 and $amount <= 20 ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$amount >= 10 and $amount <= 20
MC/DC100%2/2
$amount >= 10 and $amount <= 20
$amount >= 10
$amount <= 20
Truth table100%3/3
A and B
A= $amount >= 10B= $amount <= 20
| |||||||||||||||||||||||||||||||||||||
| 31 | 1 | $value = $suffix_five; | |||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||
| 33 | elsif( $last_digit == 1 ) { | ||||||||||||||||||||||||||||||||||||
| 34 | 3 | $value = $suffix_one; | |||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||
| 36 | ▶ | elsif( $last_digit >= 2 and $last_digit <= 4 ) { | |||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$last_digit >= 2 and $last_digit <= 4
MC/DC100%2/2
$last_digit >= 2 and $last_digit <= 4
$last_digit >= 2
$last_digit <= 4
Truth table100%3/3
A and B
A= $last_digit >= 2B= $last_digit <= 4
| |||||||||||||||||||||||||||||||||||||
| 37 | 4 | $value = $suffix_two; | |||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||
| 39 | else{ | ||||||||||||||||||||||||||||||||||||
| 40 | 3 | $value = $suffix_five; | |||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||
| 43 | 11 | return $value; | |||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||
| 47 | 1 | 1; | |||||||||||||||||||||||||||||||||||