Inflector   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 5
c 2
b 0
f 1
dl 0
loc 38
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A words() 0 3 1
A snakeCase() 0 5 1
A stuldyCase() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the PHINT package.
5
 *
6
 * (c) Jitendra Adhikari <[email protected]>
7
 *     <https://github.com/adhocore>
8
 *
9
 * Licensed under MIT license.
10
 */
11
12
namespace Ahc\Phint\Util;
13
14
class Inflector
15
{
16
    /**
17
     * StuldyCase.
18
     *
19
     * @param string $path
20
     *
21
     * @return string
22
     */
23
    public function stuldyCase(string $string): string
24
    {
25
        return str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', $string)));
26
    }
27
28
    /**
29
     * Separate words.
30
     *
31
     * @param string $path
32
     *
33
     * @return string
34
     */
35
    public function words(string $string): string
36
    {
37
        return ucwords(str_replace(['-', '_'], ' ', $string));
38
    }
39
40
    /**
41
     * Snakeize.
42
     *
43
     * @param string $path
44
     *
45
     * @return string
46
     */
47
    public function snakeCase(string $string): string
48
    {
49
        $string = \str_replace([' ', '-'], '_', $string);
50
51
        return \ltrim(\strtolower(\preg_replace('/[A-Z]([A-Z](?![a-z]))*/', '_$0', $string)), '_');
52
    }
53
}
54