1 | <?php |
||
17 | class Deferred implements DeferredInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var \Closure[] |
||
21 | */ |
||
22 | private $then = []; |
||
23 | |||
24 | /** |
||
25 | * @var ContextInterface |
||
26 | */ |
||
27 | private $ctx; |
||
28 | |||
29 | /** |
||
30 | * @var int |
||
31 | */ |
||
32 | private $offset = 0; |
||
33 | |||
34 | /** |
||
35 | * Deferred constructor. |
||
36 | * @param ContextInterface $ctx |
||
37 | * @param \Closure $then |
||
38 | */ |
||
39 | public function __construct(ContextInterface $ctx, \Closure $then = null) |
||
47 | |||
48 | /** |
||
49 | * @return int |
||
50 | */ |
||
51 | public function getOffset(): int |
||
55 | |||
56 | /** |
||
57 | * @param int $offset |
||
58 | * @return DeferredInterface |
||
59 | */ |
||
60 | public function definedIn(int $offset): DeferredInterface |
||
66 | |||
67 | /** |
||
68 | * @return ContextInterface |
||
69 | */ |
||
70 | public function getContext(): ContextInterface |
||
74 | |||
75 | /** |
||
76 | * @param \Closure $then |
||
77 | * @return Deferred|$this |
||
78 | */ |
||
79 | public function then(\Closure $then): DeferredInterface |
||
85 | |||
86 | /** |
||
87 | * @param mixed $value |
||
88 | * @return \Generator|mixed|null |
||
89 | */ |
||
90 | public function __invoke($value) |
||
94 | |||
95 | /** |
||
96 | * @param array $args |
||
97 | * @return \Generator|mixed |
||
98 | */ |
||
99 | public function invoke(...$args): \Generator |
||
111 | |||
112 | /** |
||
113 | * @param mixed $result |
||
114 | * @return \Generator |
||
115 | */ |
||
116 | private function response($result): \Generator |
||
126 | } |
||
127 |