| Conditions | 5 |
| Paths | 5 |
| Total Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 5.0592 |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | 32 | protected function doLoad(string $file) : void |
|
| 27 | { |
||
| 28 | 32 | if (! class_exists(Yaml::class)) { |
|
| 29 | throw YamlNotAvailable::new(); |
||
| 30 | } |
||
| 31 | |||
| 32 | 32 | $content = file_get_contents($file); |
|
| 33 | |||
| 34 | 32 | assert($content !== false); |
|
| 35 | |||
| 36 | try { |
||
| 37 | 32 | $config = Yaml::parse($content); |
|
| 38 | 1 | } catch (ParseException $e) { |
|
| 39 | 1 | throw YamlNotValid::malformed(); |
|
| 40 | } |
||
| 41 | |||
| 42 | 31 | if (! is_array($config)) { |
|
| 43 | throw YamlNotValid::invalid(); |
||
| 44 | } |
||
| 45 | |||
| 46 | 31 | if (isset($config['migrations_directory'])) { |
|
| 47 | 22 | $config['migrations_directory'] = $this->getDirectoryRelativeToFile( |
|
| 48 | 22 | $file, |
|
| 49 | 22 | $config['migrations_directory'] |
|
| 50 | ); |
||
| 51 | } |
||
| 52 | |||
| 53 | 31 | $this->setConfiguration($config); |
|
| 54 | 28 | } |
|
| 56 |