Skip to content

Commit df3893f

Browse files
authored
Merge pull request #221 from buckaroo-it/develop
Release v1.19.1
2 parents d818aee + 2cafec6 commit df3893f

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "buckaroo/sdk",
33
"description": "Buckaroo payment SDK",
44
"license": "MIT",
5-
"version": "1.19.0",
5+
"version": "1.19.1",
66
"type": "library",
77
"require": {
88
"php": ">=7.4|^8.0",

src/Transaction/Request/HttpClient/HttpClientFactory.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@
33
namespace Buckaroo\Transaction\Request\HttpClient;
44

55
use Buckaroo\Config\Config;
6-
use Composer\InstalledVersions;
6+
use GuzzleHttp\Client;
7+
use GuzzleHttp\ClientInterface;
8+
use function defined;
79

810
class HttpClientFactory
911
{
1012
public static function createClient(Config $config)
1113
{
12-
// Detect the installed GuzzleHttp version
13-
$versionString = InstalledVersions::getVersion('guzzlehttp/guzzle');
14-
// Extract the major version number
15-
$majorVersion = (int) explode('.', $versionString)[0];
16-
17-
// Instantiate the appropriate client based on the major version
18-
if ($majorVersion === 5) {
19-
return new GuzzleHttpClientV5($config);
14+
if (defined(ClientInterface::class . '::MAJOR_VERSION')) {
15+
$major = ClientInterface::MAJOR_VERSION;
16+
} elseif (defined(ClientInterface::class . '::VERSION')) {
17+
$major = (int)explode('.', ClientInterface::VERSION)[0];
18+
} elseif (defined(Client::class . '::VERSION')) {
19+
$major = (int)explode('.', Client::VERSION)[0];
20+
} else {
21+
$major = 7;
2022
}
21-
return new GuzzleHttpClientV7($config);
23+
24+
return $major === 5
25+
? new GuzzleHttpClientV5($config)
26+
: new GuzzleHttpClientV7($config);
2227
}
2328
}

0 commit comments

Comments
 (0)