diff --git a/composer.json b/composer.json index eb0a90c..19a7517 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ ], "require": { "php": ">=5.5.0", - "php-http/httplug": "^1.0@dev", + "php-http/httplug": "1.0.0-alpha3", "php-http/client-tools": "^0.1@dev", "guzzlehttp/guzzle": "^6.0" }, diff --git a/src/Guzzle6Promise.php b/src/Guzzle6Promise.php index a96d21d..c369033 100644 --- a/src/Guzzle6Promise.php +++ b/src/Guzzle6Promise.php @@ -5,7 +5,7 @@ use GuzzleHttp\Exception as GuzzleExceptions; use GuzzleHttp\Promise\PromiseInterface; use Http\Client\Exception as HttplugException; -use Http\Client\Promise; +use Http\Promise\Promise; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -89,37 +89,20 @@ public function getState() return $this->state; } - /** * {@inheritdoc} */ - public function getResponse() + public function wait($unwrap = true) { - if (self::FULFILLED !== $this->state) { - throw new \LogicException("Response not available for the current state"); - } + $this->promise->wait(false); - return $this->response; - } + if ($unwrap) { + if ($this->getState() == self::REJECTED) { + throw $this->exception; + } - /** - * {@inheritdoc} - */ - public function getException() - { - if (self::REJECTED !== $this->state) { - throw new \LogicException("Error not available for the current state"); + return $this->response; } - - return $this->exception; - } - - /** - * {@inheritdoc} - */ - public function wait() - { - $this->promise->wait(false); } /**