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

StringModule::studly()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
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