| Conditions | 3 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3.0123 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 5 | public static function getComposerJsonDecoded(string $path = null): array |
|
| 26 | { |
||
| 27 | 5 | $path = $path ?? self::getProjectRootDirectory() . '/composer.json'; |
|
| 28 | 5 | $contents = (string)\file_get_contents($path); |
|
| 29 | 5 | if ($contents === '') { |
|
| 30 | throw new RuntimeException('composer.json is empty'); |
||
| 31 | } |
||
| 32 | 5 | $decoded = \json_decode($contents, true); |
|
| 33 | 5 | if (\json_last_error() !== JSON_ERROR_NONE) { |
|
| 34 | 1 | throw new RuntimeException('Failed loading composer.json: ' . \json_last_error_msg()); |
|
| 35 | } |
||
| 36 | |||
| 37 | 4 | return $decoded; |
|
| 38 | } |
||
| 57 |