1 | <?php |
||
16 | class Promise implements HttpPromise |
||
17 | { |
||
18 | /** |
||
19 | * Promise status. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | private $state = HttpPromise::PENDING; |
||
24 | |||
25 | /** |
||
26 | * Adapted React promise. |
||
27 | * |
||
28 | * @var ReactPromise |
||
29 | */ |
||
30 | private $promise; |
||
31 | |||
32 | /** |
||
33 | * PSR7 received response. |
||
34 | * |
||
35 | * @var ResponseInterface |
||
36 | */ |
||
37 | private $response; |
||
38 | |||
39 | /** |
||
40 | * Execution error. |
||
41 | * |
||
42 | * @var Exception |
||
43 | */ |
||
44 | private $exception; |
||
45 | |||
46 | /** |
||
47 | * React Event Loop used for synchronous processing. |
||
48 | * |
||
49 | * @var LoopInterface |
||
50 | */ |
||
51 | private $loop; |
||
52 | |||
53 | /** |
||
54 | * Initialize the promise. |
||
55 | * |
||
56 | * @param ReactPromise $promise |
||
57 | */ |
||
58 | public function __construct(ReactPromise $promise) |
||
72 | |||
73 | /** |
||
74 | * Allow to apply callable when the promise resolve. |
||
75 | * |
||
76 | * @param callable|null $onFulfilled |
||
77 | * @param callable|null $onRejected |
||
78 | * |
||
79 | * @return ReactPromiseAdapter |
||
80 | */ |
||
81 | public function then(callable $onFulfilled = null, callable $onRejected = null) |
||
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | */ |
||
99 | public function getState() |
||
103 | |||
104 | /** |
||
105 | * Set EventLoop used for synchronous processing. |
||
106 | * |
||
107 | * @param LoopInterface $loop |
||
108 | * |
||
109 | * @return ReactPromiseAdapter |
||
110 | */ |
||
111 | public function setLoop(LoopInterface $loop) |
||
117 | |||
118 | /** |
||
119 | * {@inheritdoc} |
||
120 | */ |
||
121 | public function wait($unwrap = true) |
||
138 | } |
||
139 |