Passed
Push — master ( 229462...d74785 )
by Andreas
02:20 queued 14s
created

AbstractFileLoader::getDirectoryRelativeToFile()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Migrations\Configuration\Loader;
6
7
use function dirname;
8
use function realpath;
9
10
/**
11
 * @internal
12
 */
13
abstract class AbstractFileLoader implements Loader
14
{
15
    /**
16
     * @param array<string,string> $input
17
     *
18
     * @return array<string,string>
19
     */
20 12
    final protected function getDirectoryRelativeToFile(string $file, array $input) : array
21
    {
22 12
        foreach ($input as $ns => $dir) {
23 12
            $path = realpath(dirname($file) . '/' . $dir);
24
25 12
            $input[$ns] = $path !== false ? $path : $dir;
26
        }
27
28 12
        return $input;
29
    }
30
}
31