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