| Conditions | 5 |
| Paths | 5 |
| Total Lines | 32 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5.1158 |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | #[Override] |
||
| 24 | 30 | public function read(string $absolutePath): array |
|
| 25 | 25 | { |
|
| 26 | if (!$this->canRead($absolutePath)) { |
||
| 27 | return []; |
||
| 28 | 16 | } |
|
| 29 | |||
| 30 | self::dispatchEvent(new ReadPhpConfigEvent($absolutePath)); |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @psalm-suppress UnresolvableInclude |
||
| 34 | * |
||
| 35 | 16 | * @var null|string[]|JsonSerializable|mixed $content |
|
| 36 | */ |
||
| 37 | 16 | $content = include $absolutePath; |
|
| 38 | |||
| 39 | if ($content === null) { |
||
| 40 | return []; |
||
| 41 | 16 | } |
|
| 42 | |||
| 43 | 1 | if ($content instanceof JsonSerializable) { |
|
| 44 | 1 | /** @var array<string,mixed> $jsonSerialized */ |
|
| 45 | $jsonSerialized = $content->jsonSerialize(); |
||
| 46 | return $jsonSerialized; |
||
| 47 | 16 | } |
|
| 48 | |||
| 49 | if (!is_array($content)) { |
||
| 50 | throw new RuntimeException('The PHP config file must return an array or a JsonSerializable object!'); |
||
| 51 | } |
||
| 52 | 16 | ||
| 53 | /** @var array<string,mixed> $content */ |
||
| 54 | return $content; |
||
| 55 | 30 | } |
|
| 64 |