Completed
Push — develop ( 957723...53a684 )
by Greg
01:54
created

StringNormalizeTrait::stringNormalise()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

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