Inflector   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A camel2words() 0 9 2
1
<?php
2
3
/**
4
 * Class Inflector
5
 */
6
7
namespace EasyRedis\Helpers;
8
9
class Inflector
10
{
11
    /**
12
     * Converts a CamelCase name into space-separated words.
13
     * For example, 'PostTag' will be converted to 'Post Tag'.
14
     * @param string $name the string to be converted
15
     * @param bool $ucwords whether to capitalize the first letter in each word
16
     * @return string the resulting words
17
     */
18
    public static function camel2words($name, $ucwords = true)
19
    {
20
        $label = strtolower(trim(str_replace([
21
            '-',
22
            '_',
23
            '.',
24
        ], ' ', preg_replace('/(?<![A-Z])[A-Z]/', ' \0', $name))));
25
26
        return $ucwords ? ucwords($label) : $label;
27
    }
28
}
29