Failed Conditions
Pull Request — master (#1)
by Yo
01:55
created

PathHelper::separator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
namespace Yoanm\DefaultPhpRepository\Helper;
3
4
/**
5
 * Class PathHelper
6
 */
7
class PathHelper
8
{
9
    /**
10
     * @param string[] $componentList
11
     *
12
     * @return string
13
     */
14
    public static function implodePathComponentList(array $componentList)
15
    {
16
        $path = '';
17
        foreach ($componentList as $component) {
18
            $path .= self::appendPathSeparator($component);
19
        }
20
21
        return $path;
22
    }
23
24
    /**
25
     * @param string $component
26
     *
27
     * @return string
28
     */
29
    public static function appendPathSeparator($component)
30
    {
31
        if (strrpos($component, self::separator()) === (strlen($component) - 1)) {
32
            return $component;
33
        }
34
35
        return sprintf(
36
            '%s%s',
37
            $component,
38
            self::separator()
39
        );
40
    }
41
42
    public static function separator()
43
    {
44
        return DIRECTORY_SEPARATOR;
45
    }
46
}
47