StringModule   A
last analyzed

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
/**
6
 * Clone of Str in Laravel.
7
 */
8
class StringModule
9
{
10
    public static function camel(string $string)
11
    {
12
        return lcfirst(self::studly($string));
13
    }
14
15 16
    public static function snake(string $string)
16
    {
17 16
        $string = preg_replace('/\s+/u', '', ucwords($string));
18
19 16
        return strtolower(preg_replace('/(.)(?=[A-Z])/u', '$1_', $string));
20
    }
21
22 5
    public static function studly(string $string)
23
    {
24 5
        $string = ucwords(str_replace(['-', '_'], ' ', $string));
25
26 5
        return str_replace(' ', '', $string);
27
    }
28
}
29