diff --git a/src/Http/Adapter/GuzzleMollieHttpAdapter.php b/src/Http/Adapter/GuzzleMollieHttpAdapter.php index 5500bbab..65a7819b 100644 --- a/src/Http/Adapter/GuzzleMollieHttpAdapter.php +++ b/src/Http/Adapter/GuzzleMollieHttpAdapter.php @@ -60,7 +60,7 @@ public function factories(): Factories } /** - * Instantiate a default adapter with sane configuration for Guzzle 6 or 7. + * Instantiate a default adapter with sane configuration for Guzzle. */ public static function createDefault(): self { @@ -132,6 +132,6 @@ protected function createResponse( */ public function version(): string { - return 'Guzzle/'.ClientInterface::MAJOR_VERSION; + return 'Guzzle/' . ClientInterface::MAJOR_VERSION; } } diff --git a/src/Http/Adapter/MollieHttpAdapterPicker.php b/src/Http/Adapter/MollieHttpAdapterPicker.php index 77261d1e..117e7819 100644 --- a/src/Http/Adapter/MollieHttpAdapterPicker.php +++ b/src/Http/Adapter/MollieHttpAdapterPicker.php @@ -16,15 +16,7 @@ class MollieHttpAdapterPicker implements MollieHttpAdapterPickerContract public function pickHttpAdapter($httpClient): HttpAdapterContract { if (! $httpClient) { - if ($this->guzzleIsDetected()) { - $guzzleVersion = $this->guzzleMajorVersionNumber(); - - if ($guzzleVersion && in_array($guzzleVersion, [6, 7])) { - return GuzzleMollieHttpAdapter::createDefault(); - } - } - - return new CurlMollieHttpAdapter; + return $this->createDefaultAdapter(); } if ($httpClient instanceof HttpAdapterContract) { @@ -38,23 +30,17 @@ public function pickHttpAdapter($httpClient): HttpAdapterContract throw new UnrecognizedClientException('The provided http client or adapter was not recognized.'); } - private function guzzleIsDetected(): bool - { - return interface_exists('\\'.\GuzzleHttp\ClientInterface::class); - } - - private function guzzleMajorVersionNumber(): ?int + private function createDefaultAdapter(): HttpAdapterContract { - // Guzzle 7 - if (defined('\GuzzleHttp\ClientInterface::MAJOR_VERSION')) { - return (int) \GuzzleHttp\ClientInterface::MAJOR_VERSION; + if ($this->guzzleIsDetected()) { + return GuzzleMollieHttpAdapter::createDefault(); } - // Before Guzzle 7 - if (defined('\GuzzleHttp\ClientInterface::VERSION')) { - return (int) \GuzzleHttp\ClientInterface::VERSION[0]; - } + return new CurlMollieHttpAdapter; + } - return null; + private function guzzleIsDetected(): bool + { + return interface_exists('\\' . \GuzzleHttp\ClientInterface::class); } }