PhpFile::getConfiguration()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 21

Duplication

Lines 6
Ratio 28.57 %

Code Coverage

Tests 12
CRAP Score 4

Importance

Changes 0
Metric Value
dl 6
loc 21
ccs 12
cts 12
cp 1
rs 9.584
c 0
b 0
f 0
cc 4
nc 4
nop 0
crap 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Migrations\Configuration\Migration;
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
21 11
        $config = require $this->file;
22 11
        if ($config instanceof Configuration) {
23 1
            return $config;
24
        }
25
26 10
        assert(is_array($config));
27 10 View Code Duplication
        if (isset($config['migrations_paths'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28 5
            $config['migrations_paths'] = $this->getDirectoriesRelativeToFile(
29 5
                $config['migrations_paths'],
30 5
                $this->file
31
            );
32
        }
33
34 10
        return (new ConfigurationArray($config))->getConfiguration();
35
    }
36
}
37