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

PathHelper   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 40
ccs 0
cts 23
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A implodePathComponentList() 0 9 2
A appendPathSeparator() 0 12 2
A separator() 0 4 1
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