lib/Text/Undiacritic.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 100% 37 / 37 CC 3 SCAR 6.2
CC
3
Cov
100%
undiacritic
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
↑ Summary
1 package Text::Undiacritic;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 our $VERSION = '0.07';
6  
7 2 require Exporter;
8 2 our @ISA = qw(Exporter); ## no critic
9 2 our @EXPORT_OK = qw(undiacritic);
10  
11 2 ▶use charnames ':full';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Unicode::Normalize qw(decompose);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 11 ▶sub undiacritic {
Subroutine undiacritic: called CC=3 SCAR=11.0
Pod documented
15 11 my $characters = shift;
16  
17 11 ▶ if ( !$characters ) { return $characters; }
Branch: 1 branch
BranchTrueFalseTotal
unless ($characters) 3 8 11
18  
19 8 $characters = decompose($characters);
20 8 $characters =~ s/\p{NonspacingMark}//gxms;
21  
22 return join('',
23 map {
24 8 (ord($_) > 127)
25 12 ▶ ? do {
Branch: 1 branch
BranchTrueFalseTotal
ord $_ > 127 ? : 1 11 12
26 1 my $charname = charnames::viacode(ord $_);
27 1 $charname =~ s/\s WITH \s .+ \z//x;
28 #charnames::string_vianame($charname);
29 1 chr charnames::vianame($charname);
30 }
31 : $_;
32 }
33 split //, $characters
34 );
35 }
36  
37 2 1;
38  
39 __END__
↑ Summary