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