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 |
||
33 | 10 | public function load($file) : Configuration |
|
34 | { |
||
35 | 10 | if (! file_exists($file)) { |
|
36 | 1 | throw FileNotFound::new(); |
|
37 | } |
||
38 | |||
39 | 9 | $contents = file_get_contents($file); |
|
40 | |||
41 | 9 | assert($contents !== false); |
|
42 | |||
43 | 9 | $config = json_decode($contents, true); |
|
44 | |||
45 | 9 | if (json_last_error() !== JSON_ERROR_NONE) { |
|
46 | 1 | throw JsonNotValid::new(); |
|
47 | } |
||
48 | |||
49 | 8 | if (isset($config['migrations_paths'])) { |
|
50 | 3 | $config['migrations_paths'] = $this->getDirectoryRelativeToFile( |
|
51 | 3 | $file, |
|
52 | 3 | $config['migrations_paths'] |
|
53 | ); |
||
54 | } |
||
55 | |||
56 | 8 | return $this->arrayLoader->load($config); |
|
57 | } |
||
59 |