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

StringModule   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 19
ccs 6
cts 8
cp 0.75
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A snake() 0 5 1
A camel() 0 3 1
A studly() 0 5 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