Conditions | 2 |
Paths | 1 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
13 | private function deferredResolver(DeferredResolverInterface $resolver): \Closure |
||
|
|||
14 | { |
||
15 | 4 | return function ($root, array $args = [], $context = null, $info = null) use ($resolver): Deferred { |
|
16 | 4 | $resolverName = \get_class($resolver); |
|
17 | 4 | self::$buffer[$resolverName] = self::$buffer[$resolverName] ?? []; |
|
18 | |||
19 | 4 | $buffer = &self::$buffer[$resolverName]; |
|
20 | 4 | $buffer['results'] = []; |
|
21 | 4 | $buffer['roots'][] = $root; |
|
22 | |||
23 | 4 | return new Deferred(function () use (&$buffer, $resolver, $root, $args, $context, $info) { |
|
24 | 4 | if (empty($buffer['results'])) { |
|
25 | 4 | $buffer['results'] = $resolver->fetch($buffer['roots'], $args, $context, $info); |
|
26 | 4 | $buffer['roots'] = []; |
|
27 | } |
||
28 | |||
29 | 4 | return $resolver->pluck($root, $buffer['results']); |
|
30 | 4 | }); |
|
31 | 4 | }; |
|
32 | } |
||
33 | } |
||
34 |