Total Complexity | 5 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | class EnvEncoder implements Encoder |
||
13 | { |
||
14 | public function getDefaultOptions(): array |
||
17 | } |
||
18 | |||
19 | public function supports($value): bool |
||
20 | { |
||
21 | if (!$value instanceof Closure) { |
||
22 | return false; |
||
23 | } |
||
24 | $reflection = new ReflectionClosure($value); |
||
25 | |||
26 | $closureReflection = $reflection->getClosureScopeClass(); |
||
27 | $closureClassOwnerName = $closureReflection->getName(); |
||
28 | |||
29 | if (!is_a($closureClassOwnerName, Env::class, true)) { |
||
30 | return false; |
||
31 | } |
||
32 | |||
33 | return strpos($reflection->getCode(), 'static fn() => $_ENV') !== false; |
||
34 | } |
||
35 | |||
36 | public function encode($value, $depth, array $options, callable $encode) |
||
49 | ), |
||
50 | ); |
||
53 |