File tree Expand file tree Collapse file tree
src/Transaction/Request/HttpClient Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change 33namespace Buckaroo \Transaction \Request \HttpClient ;
44
55use Buckaroo \Config \Config ;
6- use Composer \InstalledVersions ;
6+ use GuzzleHttp \Client ;
7+ use GuzzleHttp \ClientInterface ;
8+ use function defined ;
79
810class 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}
You can’t perform that action at this time.
0 commit comments