blib/lib/Text/Slugify.pm

filter: Statementstmt 100% 22 / 22 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 90.3% 28 / 31 CC 2 SCAR 3.4
CC
2
Cov
92%
slugify
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
↑ Summary
1 package Text::Slugify;
2 # ABSTRACT: create URL slugs from text
3 2 $Text::Slugify::VERSION = '0.002';
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 our $unaccent = 0;
9  
10 2 ▶if(eval "require Text::Unaccent::PurePerl") {
Branch: 1 branch
BranchTrueFalseTotal
if (eval "require Text::Unaccent::PurePerl") 2 0 2
11 2 $unaccent = 1;
12 }
13 2 our @EXPORT_OK = qw(slugify);
14  
15 36 ▶sub slugify {
Subroutine slugify: called CC=2 SCAR=7.0
Pod undocumented
16 36 my ($text) = @_;
17  
18 36 ▶ if($unaccent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Text::Slugify::unaccent) 36 0 36
19 36 $text = Text::Unaccent::PurePerl::unac_string($text);
20 }
21  
22 36 $text =~ s/[^a-z0-9]+/-/gi;
23 36 $text =~ s/^-?(.+?)-?$/$1/;
24 36 $text =~ s/^(.+)$/\L$1/;
25 36 return $text;
26 }
27  
28 2 1;
29  
30 __END__
↑ Summary