Completed
Push — master ( ab7ebf...740609 )
by Grégoire
02:23
created

PhpFile::getConfiguration()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 11
c 1
b 0
f 0
nc 4
nop 0
dl 0
loc 19
ccs 12
cts 12
cp 1
crap 4
rs 9.9
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Migrations\Configuration\Configuration;
6
7
use Doctrine\Migrations\Configuration\Configuration;
8
use Doctrine\Migrations\Configuration\Exception\FileNotFound;
9
use function assert;
10
use function file_exists;
11
use function is_array;
12
13
final class PhpFile extends ConfigurationFile
14
{
15 12
    public function getConfiguration() : Configuration
16
    {
17 12
        if (! file_exists($this->file)) {
18 1
            throw FileNotFound::new($this->file);
19
        }
20 11
        $config = require $this->file;
21 11
        if ($config instanceof Configuration) {
22 1
            return $config;
23
        }
24
25 10
        assert(is_array($config));
26 10
        if (isset($config['migrations_paths'])) {
27 5
            $config['migrations_paths'] = $this->getDirectoriesRelativeToFile(
28 5
                $config['migrations_paths'],
29 5
                $this->file
30
            );
31
        }
32
33 10
        return (new ConfigurationArray($config))->getConfiguration();
34
    }
35
}
36