class HttpRejectedPromise
Hierarchy
- class \Http\Client\Promise\HttpRejectedPromise implements \Http\Promise\Promise
Expanded class hierarchy of HttpRejectedPromise
File
-
vendor/
php-http/ httplug/ src/ Promise/ HttpRejectedPromise.php, line 8
Namespace
Http\Client\PromiseView source
final class HttpRejectedPromise implements Promise {
/**
* @var Exception
*/
private $exception;
public function __construct(Exception $exception) {
$this->exception = $exception;
}
public function then(?callable $onFulfilled = null, ?callable $onRejected = null) {
if (null === $onRejected) {
return $this;
}
try {
$result = $onRejected($this->exception);
if ($result instanceof Promise) {
return $result;
}
return new HttpFulfilledPromise($result);
} catch (Exception $e) {
return new self($e);
}
}
public function getState() {
return Promise::REJECTED;
}
public function wait($unwrap = true) {
if ($unwrap) {
throw $this->exception;
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
HttpRejectedPromise::$exception | private | property | ||
HttpRejectedPromise::getState | public | function | Returns the state of the promise, one of PENDING, FULFILLED or REJECTED. | Overrides Promise::getState |
HttpRejectedPromise::then | public | function | Adds behavior for when the promise is resolved or rejected (response will be available, or error happens). | Overrides Promise::then |
HttpRejectedPromise::wait | public | function | Wait for the promise to be fulfilled or rejected. | Overrides Promise::wait |
HttpRejectedPromise::__construct | public | function | ||
Promise::FULFILLED | constant | Promise has been fulfilled. | ||
Promise::PENDING | constant | Promise has not been fulfilled or rejected. | ||
Promise::REJECTED | constant | Promise has been rejected. |