Completed
Push — master ( 129456...b25aba )
by Joe
01:45
created

StringModule::camel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace PhpWinTools\Support;
4
5
class StringModule
6
{
7
    public static function camel(string $string)
8
    {
9
        return lcfirst(self::studly($string));
10
    }
11
12 8
    public static function snake(string $string)
13
    {
14 8
        $string = preg_replace('/\s+/u', '', ucwords($string));
15
16 8
        return strtolower(preg_replace('/(.)(?=[A-Z])/u', '$1_', $string));
17
    }
18
19 5
    public static function studly(string $string)
20
    {
21 5
        $string = ucwords(str_replace(['-', '_'], ' ', $string));
22
23 5
        return str_replace(' ', '', $string);
24
    }
25
}
26