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

Commit a3ad3b9

Browse files
committed
Minor changes
1 parent 64990cc commit a3ad3b9

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
{
99
"name": "David de Boer",
1010
"email": "[email protected]"
11+
},
12+
{
13+
"name": "Márk Sági-Kazár",
14+
"email": "[email protected]"
1115
}
1216
],
1317
"require": {

src/Guzzle6HttpAdapter.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Http\Adapter;
1313

1414
use GuzzleHttp\Client;
15+
use GuzzleHttp\ClientInterface;
1516
use GuzzleHttp\Exception\RequestException;
1617
use GuzzleHttp\Pool;
1718
use Http\Adapter\Common\Exception\HttpAdapterException;
@@ -27,9 +28,14 @@
2728
class Guzzle6HttpAdapter implements HttpAdapter
2829
{
2930
/**
30-
* @param Client $client
31+
* @var ClientInterface
3132
*/
32-
public function __construct(Client $client = null)
33+
private $client;
34+
35+
/**
36+
* @param ClientInterface|null $client
37+
*/
38+
public function __construct(ClientInterface $client = null)
3339
{
3440
$this->client = $client ?: new Client();
3541
}
@@ -43,8 +49,8 @@ public function sendRequest(RequestInterface $request, array $options = [])
4349

4450
try {
4551
return $this->client->send($request, $options);
46-
} catch (RequestException $exception) {
47-
throw $this->createException($exception);
52+
} catch (RequestException $e) {
53+
throw $this->createException($e);
4854
}
4955
}
5056

@@ -55,11 +61,7 @@ public function sendRequests(array $requests, array $options = [])
5561
{
5662
$options = $this->buildOptions($options);
5763

58-
$results = Pool::batch(
59-
$this->client,
60-
$requests,
61-
$options
62-
);
64+
$results = Pool::batch($this->client, $requests, $options);
6365

6466
$exceptions = [];
6567
$responses = [];
@@ -88,7 +90,7 @@ public function getName()
8890
}
8991

9092
/**
91-
* Convert Guzzle exception into HttpAdapter exception
93+
* Converts a Guzzle exception into an HttpAdapter exception
9294
*
9395
* @param RequestException $exception
9496
*
@@ -116,7 +118,10 @@ private function createException(RequestException $exception)
116118
*/
117119
private function buildOptions(array $options)
118120
{
119-
$guzzleOptions = [];
121+
$guzzleOptions = [
122+
'http_errors' => false,
123+
'allow_redirects' => false,
124+
];
120125

121126
if (isset($options['timeout'])) {
122127
$guzzleOptions['connect_timeout'] = $options['timeout'];

0 commit comments

Comments
 (0)