Failed Conditions
Pull Request — master (#911)
by Asmir
02:45
created

JsonFile   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 26
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfiguration() 0 24 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 file_get_contents;
12
use function json_decode;
13
use function json_last_error;
14
use const JSON_ERROR_NONE;
15
16
final class JsonFile extends ConfigurationFile
17
{
18 10
    public function getConfiguration() : Configuration
19
    {
20 10
        if (! file_exists($this->file)) {
21 1
            throw FileNotFound::new($this->file);
22
        }
23
24 9
        $contents = file_get_contents($this->file);
25
26 9
        assert($contents !== false);
27
28 9
        $config = json_decode($contents, true);
29
30 9
        if (json_last_error() !== JSON_ERROR_NONE) {
31 1
            throw JsonNotValid::new();
0 ignored issues
show
Bug introduced by
The type Doctrine\Migrations\Conf...\Migration\JsonNotValid was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
        }
33
34 8
        if (isset($config['migrations_paths'])) {
35 3
            $config['migrations_paths'] = $this->getDirectoriesRelativeToFile(
36 3
                $config['migrations_paths'],
37 3
                $this->file
38
            );
39
        }
40
41 8
        return (new ConfigurationArray($config))->getConfiguration();
42
    }
43
}
44