Skip to content

Commit 2148307

Browse files
Uses the Versions package to better determine the Guzzle version (#270)
1 parent a01a7d4 commit 2148307

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Client.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,19 @@ public function __construct(CredentialsInterface $credentials, $options = [], ?C
124124
if (is_null($client)) {
125125
// Since the user did not pass a client, try and make a client
126126
// using the Guzzle 6 adapter or Guzzle 7 (depending on availability)
127-
/** @noinspection ClassConstantCanBeUsedInspection */
128-
if (class_exists('\GuzzleHttp\Client')) {
129-
$client = new \GuzzleHttp\Client();
130-
} elseif (class_exists('\Http\Adapter\Guzzle6\Client')) {
127+
list($guzzleVersion) = explode('@', Versions::getVersion('guzzlehttp/guzzle'), 1);
128+
$guzzleVersion = (float) $guzzleVersion;
129+
130+
if ($guzzleVersion >= 6.0 && $guzzleVersion < 7) {
131131
/** @noinspection CallableParameterUseCaseInTypeContextInspection */
132132
/** @noinspection PhpUndefinedNamespaceInspection */
133133
/** @noinspection PhpUndefinedClassInspection */
134134
$client = new \Http\Adapter\Guzzle6\Client();
135135
}
136+
137+
if ($guzzleVersion >= 7.0 && $guzzleVersion < 8.0) {
138+
$client = new \GuzzleHttp\Client();
139+
}
136140
}
137141

138142
$this->setHttpClient($client);

0 commit comments

Comments
 (0)