Util::fixRelativePaths()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php namespace Arcanedev\Composer\Utilities;
2
3
/**
4
 * Class     Util
5
 *
6
 * @package  Arcanedev\Composer\Utilities
7
 * @author   ARCANEDEV <[email protected]>
8
 */
9
class Util
10
{
11
    /* -----------------------------------------------------------------
12
     |  Main Methods
13
     | -----------------------------------------------------------------
14
     */
15
16
    /**
17
     * Fix a collection of paths that are relative to this package to be
18
     * relative to the base package.
19
     *
20
     * @param  string  $base
21
     * @param  array   $paths
22
     *
23
     * @return array
24
     */
25 9
    public static function fixRelativePaths($base, array $paths)
26
    {
27 9
        $base = dirname($base);
28 9
        $base = ($base === '.') ? '' : "{$base}/";
29
30
        array_walk_recursive($paths, function (&$path) use ($base) {
31 9
            $path = "{$base}{$path}";
32 9
        });
33
34 9
        return $paths;
35
    }
36
}
37