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