Passed
Pull Request — master (#6)
by
unknown
02:13
created

Name::camelize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2.0023

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 2
eloc 12
c 2
b 1
f 0
nc 2
nop 1
dl 0
loc 18
ccs 11
cts 12
cp 0.9167
crap 2.0023
rs 9.8666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace drupol\ComposerPackages\Utils;
6
7
final class Name
8
{
9 5
    public static function camelize(string $str): string
10
    {
11 5
        $str = \preg_replace(
12 5
            '/[^a-z0-9]+/i',
13 5
            ' ',
14
            $str
15
        );
16
17 5
        if (null === $str) {
18
            return '';
19
        }
20
21 5
        return \lcfirst(
22 5
            \str_replace(
23 5
                ' ',
24 5
                '',
25 5
                \ucwords(
26 5
                    $str
27
                )
28
            )
29
        );
30
    }
31
}
32