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

Commit c2fc7ee

Browse files
committed
Update async call with new promise package and interface update
1 parent 2103114 commit c2fc7ee

File tree

2 files changed

+11
-28
lines changed

2 files changed

+11
-28
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
],
1717
"require": {
1818
"php": ">=5.5.0",
19-
"php-http/httplug": "^1.0@dev",
20-
"php-http/client-tools": "^0.1@dev",
19+
"php-http/httplug": "dev-feature/promise-dep as 1.0.0",
20+
"php-http/client-tools": "dev-feature/promise-dep",
2121
"guzzlehttp/guzzle": "^6.0"
2222
},
2323
"require-dev": {
2424
"ext-curl": "*",
25-
"php-http/adapter-integration-tests": "dev-master"
25+
"php-http/adapter-integration-tests": "dev-feature/promise-update"
2626
},
2727
"provide": {
2828
"php-http/client-implementation": "1.0",

src/Guzzle6Promise.php

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use GuzzleHttp\Exception as GuzzleExceptions;
66
use GuzzleHttp\Promise\PromiseInterface;
77
use Http\Client\Exception as HttplugException;
8-
use Http\Client\Promise;
8+
use Http\Promise\Promise;
99
use Psr\Http\Message\RequestInterface;
1010
use Psr\Http\Message\ResponseInterface;
1111

@@ -89,37 +89,20 @@ public function getState()
8989
return $this->state;
9090
}
9191

92-
9392
/**
9493
* {@inheritdoc}
9594
*/
96-
public function getResponse()
95+
public function wait($unwrap = true)
9796
{
98-
if (self::FULFILLED !== $this->state) {
99-
throw new \LogicException("Response not available for the current state");
100-
}
97+
$this->promise->wait(false);
10198

102-
return $this->response;
103-
}
99+
if ($unwrap) {
100+
if ($this->getState() == self::REJECTED) {
101+
throw $this->exception;
102+
}
104103

105-
/**
106-
* {@inheritdoc}
107-
*/
108-
public function getException()
109-
{
110-
if (self::REJECTED !== $this->state) {
111-
throw new \LogicException("Error not available for the current state");
104+
return $this->response;
112105
}
113-
114-
return $this->exception;
115-
}
116-
117-
/**
118-
* {@inheritdoc}
119-
*/
120-
public function wait()
121-
{
122-
$this->promise->wait(false);
123106
}
124107

125108
/**

0 commit comments

Comments
 (0)