function Promise::__construct
Same name in this branch
- 11.1.x vendor/react/promise/src/Promise.php \React\Promise\Promise::__construct()
- 11.1.x vendor/guzzlehttp/promises/src/Promise.php \GuzzleHttp\Promise\Promise::__construct()
File
-
vendor/
php-http/ guzzle7-adapter/ src/ Promise.php, line 47
Class
- Promise
- Wrapper around Guzzle promises.
Namespace
Http\Adapter\Guzzle7Code
public function __construct(PromiseInterface $promise, RequestInterface $request) {
$this->request = $request;
$this->state = self::PENDING;
$this->promise = $promise->then(function ($response) {
$this->response = $response;
$this->state = self::FULFILLED;
return $response;
}, function ($reason) {
$this->state = self::REJECTED;
if ($reason instanceof HttplugException) {
$this->exception = $reason;
}
elseif ($reason instanceof GuzzleExceptions\GuzzleException) {
$this->exception = $this->handleException($reason);
}
elseif ($reason instanceof \Throwable) {
$this->exception = new HttplugException\TransferException('Invalid exception returned from Guzzle7', 0, $reason);
}
else {
$this->exception = new UnexpectedValueException('Reason returned from Guzzle7 must be an Exception');
}
throw $this->exception;
});
}