StringInflector::nameToCode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
nc 1
cc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of AppName.
5
 *
6
 * (c) Monofony
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace App\Formatter;
13
14
final class StringInflector
15
{
16
    /**
17
     * @param string $value
18
     *
19
     * @return string
20
     */
21
    public static function nameToCode($value)
22
    {
23
        return str_replace([' ', '-'], '_', $value);
24
    }
25
26
    /**
27
     * @param string $value
28
     *
29
     * @return string
30
     */
31
    public static function nameToLowercaseCode($value)
32
    {
33
        return strtolower(self::nameToCode($value));
34
    }
35
36
    /**
37
     * @param string $value
38
     *
39
     * @return string
40
     */
41
    public static function nameToUppercaseCode($value)
42
    {
43
        return strtoupper(self::nameToCode($value));
44
    }
45
46
    private function __construct()
47
    {
48
    }
49
}
50