Completed
Push — master ( 3b6465...96f4b7 )
by compolom
25s queued 11s
created

Helper::normalizeMethodName()   A

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
cc 1
nc 1
nop 1
1
<?php
2
3
namespace ComposerJson;
4
5
trait Helper
6
{
7
    /**
8
     * Normalize parameter from camelCase to composer-case
9
     *
10
     * @param string $name
11
     *
12
     * @return string
13
     */
14
    private function normalize(string $name): string
15
    {
16
        return strtolower(ltrim(preg_replace('/[A-Z]([A-Z](?![a-z]))*/', '-$0', $name), '-'));
17
    }
18
19
    /**
20
     * Convert string like "require-dev" to "requireDev"
21
     *
22
     * @param string $name
23
     *
24
     * @return string
25
     */
26
    private function denormalize(string $name): string
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
27
    {
28
        $exploded = array_map(function ($item) {
29
            return ucfirst($item);
30
        }, explode('-', $name));
31
32
        return lcfirst(implode('', $exploded));
33
    }
34
35
    /**
36
     * Convert string to normal name
37
     *
38
     * @param string $name
39
     *
40
     * @return string
41
     */
42
    private function normalizeMethodName(string $name): string
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
43
    {
44
        return str_replace(' ', '', ucwords(implode(' ', explode('-', $name))));
45
    }
46
}
47