Canonicalizer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 17
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A canonicalize() 0 10 3
1
<?php
2
3
/*
4
 * This file is part of the DoyoUserBundle project.
5
 *
6
 * (c) Anthonius Munthi <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Doyo\UserBundle\Util;
15
16
class Canonicalizer implements CanonicalizerInterface
17
{
18
    /**
19
     * @param $string
20
     *
21
     * @return false|mixed|string|string[]|void|null
22
     */
23 16
    public function canonicalize($string)
24
    {
25 16
        if (null === $string) {
26 1
            return;
27
        }
28 16
        $encoding = mb_detect_encoding($string, mb_detect_order(), true);
29
30 16
        return $encoding
31 16
            ? mb_convert_case($string, MB_CASE_LOWER, $encoding)
32 16
            : mb_convert_case($string, MB_CASE_LOWER);
33
    }
34
}
35