Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2declare(strict_types=1);
3/**
4 * Pop PHP Framework (https://www.popphp.org/)
5 *
6 * @link       https://github.com/popphp/popphp-framework
7 * @author     Nick Sagona, III <nick@popphp.org>
8 * @copyright  Copyright (c) 2009-2026 Nick Sagona, III
9 * @license    https://www.popphp.org/license     New BSD License
10 */
11
12/**
13 * @namespace
14 */
15namespace Pop\Http\Promise;
16
17use Pop\Http\Client;
18use Pop\Http\Client\Response;
19use Pop\Http\Client\Handler\CurlMulti;
20use Pop\Utils\CallableObject;
21
22/**
23 * HTTP promise interface
24 *
25 * @category   Pop
26 * @package    Pop\Http
27 * @author     Nick Sagona, III <nick@popphp.org>
28 * @copyright  Copyright (c) 2009-2026 Nick Sagona, III
29 * @license    https://www.popphp.org/license     New BSD License
30 * @version    6.0.0
31 */
32interface PromiseInterface
33{
34
35    /**
36     * Method to set client promiser
37     *
38     * @param  Client|CurlMulti $promiser
39     * @return PromiseInterface
40     */
41    public function setPromiser(Client|CurlMulti $promiser): PromiseInterface;
42
43    /**
44     * Method to get client promiser
45     *
46     * @return Client|CurlMulti
47     */
48    public function getPromiser(): Client|CurlMulti;
49
50    /**
51     * Method to check client promiser
52     *
53     * @return bool
54     */
55    public function hasPromiser(): bool;
56
57    /**
58     * Method to set success callable
59     *
60     * @param  mixed $success
61     * @return PromiseInterface
62     */
63    public function setSuccess(mixed $success): PromiseInterface;
64
65    /**
66     * Method to get success callable
67     *
68     * @param  ?int $i
69     * @return array|CallableObject|null
70     */
71    public function getSuccess(?int $i = null): array|CallableObject|null;
72
73    /**
74     * Method to check success callable
75     *
76     * @param  ?int $i
77     * @return bool
78     */
79    public function hasSuccess(?int $i = null): bool;
80
81    /**
82     * Method to set failure callable
83     *
84     * @param  mixed $failure
85     * @return PromiseInterface
86     */
87    public function setFailure(mixed $failure): PromiseInterface;
88
89    /**
90     * Method to get failure callable
91     *
92     * @return CallableObject|null
93     */
94    public function getFailure(): CallableObject|null;
95
96    /**
97     * Method to check failure callable
98     *
99     * @return bool
100     */
101    public function hasFailure(): bool;
102
103    /**
104     * Method to set cancel callable
105     *
106     * @param  mixed $cancel
107     * @return PromiseInterface
108     */
109    public function setCancel(mixed $cancel): PromiseInterface;
110
111    /**
112     * Method to get cancel callable
113     *
114     * @return CallableObject|null
115     */
116    public function getCancel(): CallableObject|null;
117
118    /**
119     * Method to check cancel callable
120     *
121     * @return bool
122     */
123    public function hasCancel(): bool;
124
125    /**
126     * Method to set finally callable
127     *
128     * @param  mixed $finally
129     * @return PromiseInterface
130     */
131    public function setFinally(mixed $finally): PromiseInterface;
132
133    /**
134     * Method to get finally callable
135     *
136     * @return CallableObject|null
137     */
138    public function getFinally(): CallableObject|null;
139
140    /**
141     * Method to check finally callable
142     *
143     * @return bool
144     */
145    public function hasFinally(): bool;
146
147    /**
148     * Method to set current state
149     *
150     * @param  string $state
151     * @return PromiseInterface
152     */
153    public function setState(string $state): PromiseInterface;
154
155    /**
156     * Method to get current state
157     *
158     * @return string
159     */
160    public function getState(): string;
161
162    /**
163     * Method to check current state
164     *
165     * @return bool
166     */
167    public function hasState(): bool;
168
169    /**
170     * Determine is the promise is pending
171     *
172     * @return bool
173     */
174    public function isPending(): bool;
175
176    /**
177     * Determine is the promise is fulfilled
178     *
179     * @return bool
180     */
181    public function isFulfilled(): bool;
182
183    /**
184     * Determine is the promise is rejected
185     *
186     * @return bool
187     */
188    public function isRejected(): bool;
189
190    /**
191     * Determine is the promise is cancelled
192     *
193     * @return bool
194     */
195    public function isCancelled(): bool;
196
197    /**
198     * Then method
199     *
200     * @param  mixed $success
201     * @param  bool  $resolve
202     * @return PromiseInterface
203     */
204    public function then(mixed $success, bool $resolve = false): PromiseInterface;
205
206    /**
207     * Method to set failure callable
208     *
209     * @param  mixed $failure
210     * @param  bool $resolve
211     * @return PromiseInterface
212     */
213    public function catch(mixed $failure, bool $resolve = false): PromiseInterface;
214
215    /**
216     * Method to set finally callable
217     *
218     * @param  mixed $finally
219     * @param  bool $resolve
220     * @return PromiseInterface
221     */
222    public function finally(mixed $finally, bool $resolve = false): PromiseInterface;
223
224    /**
225     * Wait method
226     *
227     * @param  bool $unwrap
228     * @return Response|string|array|null
229     */
230    public function wait(bool $unwrap = true): Response|string|array|null;
231
232    /**
233     * Resolve method
234     *
235     * @return void
236     */
237    public function resolve(): void;
238
239    /**
240     * Cancel method
241     *
242     * @return void
243     */
244    public function cancel(): void;
245
246    /**
247     * Forward method
248     *
249     * @param  PromiseInterface $nextPromise
250     * @param  int              $i
251     * @return PromiseInterface
252     */
253    public function forward(PromiseInterface $nextPromise, int $i = 0): PromiseInterface;
254
255}