Transliterator.pm

filter: Statementstmt 100% 23 / 23 Branchbran 62.5% 5 / 8 Conditioncond 71.4% 5 / 7 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 84.7% 39 / 46 CC 8 SCAR 19.2
CC
8
Cov
87%
new
8.3
BEGIN
1.0
BEGIN
1.0
CRAP 6.8
« Transliterator/Unaccent.pm ↑ Summary
1 package Text::Transliterator;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 3 our $VERSION = '1.06';
6
7 5 ▶sub new {
Subroutine new: called CC=8 SCAR=21.2
Pod documented
8 5 my $class = shift;
9 5 my ($from, $to);
10
11 # first arguments : either a hashref, or a pair of strings
12 5 ▶ if ((ref $_[0] || '') eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $_[0] || '') eq 'HASH') { } 3 2 5
Condition100%2/2
ref $_[0] || ''
l!l
32
MC/DC100%1/1
ref $_[0] || ''
ref $_[0]
Truth table100%2/2
A
A= ref $_[0]
Aresult
11
00
13 3 my $map = shift;
14 3 $from = join "", keys %$map;
15 3 $to = join "", values %$map;
16 }
17 else {
18 2 $from = shift;
19 2 $to = shift;
20 2 ▶ defined $from and defined $to
Branch: 1 branch
BranchTrueFalseTotal
defined $from and defined $to or die "Text::Transliterator->new(\$from, \$to): invalid args" 2 0 2
Condition33%1/3
defined $from and defined $to
!ll&&!rl&&r
002
MC/DC0%0/2
defined $from and defined $to
defined $from defined $to
Truth table33%1/3
A and B
A= defined $fromB= defined $to
ABresult
0X0
100
111
21 or die 'Text::Transliterator->new($from, $to): invalid args';
22 }
23
24 # remaining arguments
25 5 ▶ my $modifiers = shift || '';
Condition100%2/2
shift() || ''
l!l
23
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
26 not @_
27 5 ▶ or die 'Text::Transliterator->new(): too many args';
Branch: 1 branch
BranchTrueFalseTotal
@_ and die "Text::Transliterator->new(): too many args" 0 5 5
28
29 # build the coderef.
30 # Returns the list of tr/../../ results.
31 # In scalar context, returns the last item (for compatibility with the previous API)
32 5 my $src = "sub {my \@l = map {tr[$from][$to]$modifiers} \@_; return wantarray ? \@l : \$l[-1]}";
33 5 local $@;
34 5 ▶ my $coderef = eval $src or die "Text::Transliterator: error in compiling the tr function: $@";
Branch: 1 branch
BranchTrueFalseTotal
my $coderef = eval $src or die "Text::Transliterator: error in compiling the tr function: $@" 5 0 5
35
36 5 return $coderef;
37 }
38
39
40 3 1; # End of Text::Transliterator
41
42 __END__
« Transliterator/Unaccent.pm ↑ Summary