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

Commit 8d12420

Browse files
committed
Remove useless options parameters
1 parent 977a6dc commit 8d12420

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

src/Guzzle6HttpAdapter.php

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Http\Client\Exception\BatchException;
1919
use Http\Client\Exception\HttpException;
2020
use Http\Client\Exception\NetworkException;
21+
use Http\Client\Exception;
2122
use Http\Client\HttpClient;
2223
use Http\Client\Utils\BatchResult;
2324
use Psr\Http\Message\RequestInterface;
@@ -33,19 +34,12 @@ class Guzzle6HttpAdapter implements HttpClient
3334
*/
3435
private $client;
3536

36-
/**
37-
* @var array Options to pass when sending one or multiple requests with guzzle
38-
*/
39-
private $options;
40-
4137
/**
4238
* @param ClientInterface|null $client Guzzle client
43-
* @param array $options Options to pass when sending one or multiple requests with guzzle
4439
*/
45-
public function __construct(ClientInterface $client = null, array $options = [])
40+
public function __construct(ClientInterface $client = null)
4641
{
47-
$this->client = $client ?: new Client();
48-
$this->options = $this->buildOptions($options);
42+
$this->client = $client ?: new Client();
4943
}
5044

5145
/**
@@ -54,7 +48,7 @@ public function __construct(ClientInterface $client = null, array $options = [])
5448
public function sendRequest(RequestInterface $request)
5549
{
5650
try {
57-
return $this->client->send($request, $this->options);
51+
return $this->client->send($request);
5852
} catch (RequestException $e) {
5953
throw $this->createException($e);
6054
}
@@ -65,7 +59,7 @@ public function sendRequest(RequestInterface $request)
6559
*/
6660
public function sendRequests(array $requests)
6761
{
68-
$poolResult = Pool::batch($this->client, $requests, ['options' => $this->options]);
62+
$poolResult = Pool::batch($this->client, $requests);
6963
$batchResult = new BatchResult();
7064

7165
foreach ($poolResult as $index => $result) {
@@ -90,7 +84,7 @@ public function sendRequests(array $requests)
9084
*
9185
* @param RequestException $exception
9286
*
93-
* @return HttpException|NetworkException Return an HttpException if response is available, NetworkException otherwise
87+
* @return Exception
9488
*/
9589
private function createException(RequestException $exception)
9690
{
@@ -100,26 +94,4 @@ private function createException(RequestException $exception)
10094

10195
return new NetworkException($exception->getMessage(), $exception->getRequest(), $exception);
10296
}
103-
104-
/**
105-
* Builds options for Guzzle
106-
*
107-
* @param array $options
108-
*
109-
* @return array
110-
*/
111-
private function buildOptions(array $options)
112-
{
113-
$guzzleOptions = [
114-
'http_errors' => false,
115-
'allow_redirects' => false,
116-
];
117-
118-
if (isset($options['timeout'])) {
119-
$guzzleOptions['connect_timeout'] = $options['timeout'];
120-
$guzzleOptions['timeout'] = $options['timeout'];
121-
}
122-
123-
return $guzzleOptions;
124-
}
12597
}

0 commit comments

Comments
 (0)