Skip to content
This repository was archived by the owner on Jan 6, 2024. It is now read-only.

Update async call with new promise package and interface update #15

Merged
merged 1 commit into from
Dec 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
33 changes: 8 additions & 25 deletions src/Guzzle6Promise.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}

/**
Expand Down