Util   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A joinPaths() 0 12 2
1
<?php
2
3
namespace SilverStripe\VendorPlugin;
4
5
class Util
6
{
7
    /**
8
     * Join paths
9
     *
10
     * @param array ...$parts
11
     * @return string
12
     */
13
    public static function joinPaths(...$parts)
14
    {
15
        $combined = null;
16
        $parts = array_filter($parts);
17
        array_walk_recursive($parts, function ($part) use (&$combined) {
18
            // Normalise path
19
            $part = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $part);
20
            $combined = $combined
21
                ? (rtrim($combined, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $part)
22
                : $part;
23
        });
24
        return $combined;
25
    }
26
}
27