44
55namespace Http \Client \Common ;
66
7- use Http \Client \Exception as HttplugException ;
87use Http \Client \HttpAsyncClient ;
98use Http \Client \HttpClient ;
10- use Http \Client \Promise \HttpFulfilledPromise ;
11- use Http \Client \Promise \HttpRejectedPromise ;
129use Psr \Http \Client \ClientInterface ;
1310use Psr \Http \Message \RequestInterface ;
1411use Psr \Http \Message \ResponseInterface ;
@@ -24,7 +21,7 @@ final class PluginClient implements HttpClient, HttpAsyncClient
2421 /**
2522 * An HTTP async client.
2623 *
27- * @var HttpAsyncClient|HttpClient
24+ * @var HttpAsyncClient
2825 */
2926 private $ client ;
3027
@@ -71,22 +68,7 @@ public function __construct($client, array $plugins = [], array $options = [])
7168 */
7269 public function sendRequest (RequestInterface $ request ): ResponseInterface
7370 {
74- // If we don't have an http client, use the async call
75- if (!($ this ->client instanceof ClientInterface)) {
76- return $ this ->sendAsyncRequest ($ request )->wait ();
77- }
78-
79- // Else we want to use the synchronous call of the underlying client, and not the async one in the case
80- // we have both an async and sync call
81- $ pluginChain = $ this ->createPluginChain ($ this ->plugins , function (RequestInterface $ request ) {
82- try {
83- return new HttpFulfilledPromise ($ this ->client ->sendRequest ($ request ));
84- } catch (HttplugException $ exception ) {
85- return new HttpRejectedPromise ($ exception );
86- }
87- });
88-
89- return $ pluginChain ($ request )->wait ();
71+ return $ this ->sendAsyncRequest ($ request )->wait ();
9072 }
9173
9274 /**
0 commit comments