Text   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 1
b 0
f 0
dl 0
loc 20
ccs 0
cts 8
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A toAscii() 0 12 2
1
<?php
2
3
namespace Nip\Utility;
4
5
/**
6
 * Class Text
7
 * @package Nip\Utility
8
 */
9
class Text
10
{
11
    /**
12
     * @param $str
13
     * @param array $replace
14
     * @param string $delimiter
15
     * @return mixed|string
16
     */
17
    public static function toAscii($str, $replace = [], $delimiter = '-')
18
    {
19
        if (!empty($replace)) {
20
            $str = str_replace((array) $replace, ' ', $str);
21
        }
22
23
        $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
24
        $clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean);
25
        $clean = strtolower(trim($clean, '-'));
26
        $clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean);
27
28
        return $clean;
29
    }
30
}
31