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