String.php ➔ mb_normalise()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
1
<?php
2
3
namespace App\Lib;
4
5
/**
6
 * Normalise a string (remove diacritics)
7
 *
8
 * @param string $string
9
 *
10
 * @return string
11
 */
12
function mb_normalise($string)
13
{
14
    $string = html_entity_decode(
15
        preg_replace(
16
            '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|tilde|uml);~i',
17
            '$1',
18
            htmlentities($string)
19
        ),
20
        ENT_QUOTES,
21
        'UTF-8'
22
    );
23
    return preg_replace('/[^A-z0-9]/', '_', mb_strtolower($string));
24
}
25