Conditions | 4 |
Paths | 4 |
Total Lines | 24 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | 10 | public function getConfiguration() : Configuration |
|
20 | { |
||
21 | 10 | if (! file_exists($this->file)) { |
|
22 | 1 | throw FileNotFound::new($this->file); |
|
23 | } |
||
24 | |||
25 | 9 | $contents = file_get_contents($this->file); |
|
26 | |||
27 | 9 | assert($contents !== false); |
|
28 | |||
29 | 9 | $config = json_decode($contents, true); |
|
30 | |||
31 | 9 | if (json_last_error() !== JSON_ERROR_NONE) { |
|
32 | 1 | throw JsonNotValid::new(); |
|
33 | } |
||
34 | |||
35 | 8 | if (isset($config['migrations_paths'])) { |
|
36 | 3 | $config['migrations_paths'] = $this->getDirectoriesRelativeToFile( |
|
37 | 3 | $config['migrations_paths'], |
|
38 | 3 | $this->file |
|
39 | ); |
||
40 | } |
||
41 | |||
42 | 8 | return (new ConfigurationArray($config))->getConfiguration(); |
|
43 | } |
||
45 |