Conditions | 3 |
Paths | 3 |
Total Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3.0123 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
39 | 2 | public static function getComposerJsonDecoded(string $path = null): array |
|
40 | { |
||
41 | 2 | $path = $path ?? self::getProjectRootDirectory().'/composer.json'; |
|
42 | 2 | $contents = (string)\file_get_contents($path); |
|
43 | 2 | if ('' === $contents) { |
|
44 | throw new \RuntimeException('composer.json is empty'); |
||
45 | } |
||
46 | 2 | $decoded = \json_decode($contents, true); |
|
47 | 2 | if (JSON_ERROR_NONE !== \json_last_error()) { |
|
48 | 1 | throw new \RuntimeException('Failed loading composer.json: '.\json_last_error_msg()); |
|
49 | } |
||
50 | |||
51 | 1 | return $decoded; |
|
52 | } |
||
54 |