From e4db28ebbbed866ec67e06eca48065a7fe3db797 Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Mon, 30 Oct 2023 10:41:10 +0100 Subject: [PATCH] Add support for an union of ClientInterfaces --- src/Client/PayPalClient.php | 43 +++++++++---------------------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/src/Client/PayPalClient.php b/src/Client/PayPalClient.php index a4935bc3..e48578c8 100644 --- a/src/Client/PayPalClient.php +++ b/src/Client/PayPalClient.php @@ -13,7 +13,8 @@ namespace Sylius\PayPalPlugin\Client; -use GuzzleHttp\ClientInterface; +use GuzzleHttp\ClientInterface as DeprecatedClientInterface; +use Psr\Http\Client\ClientInterface; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; use Psr\Http\Message\ResponseInterface; @@ -27,40 +28,16 @@ final class PayPalClient implements PayPalClientInterface { - private ClientInterface $client; - - private LoggerInterface $logger; - - private UuidProviderInterface $uuidProvider; - - private PayPalConfigurationProviderInterface $payPalConfigurationProvider; - - private ChannelContextInterface $channelContext; - - private string $baseUrl; - - private int $requestTrialsLimit; - - private bool $loggingLevelIncreased; - public function __construct( - ClientInterface $client, - LoggerInterface $logger, - UuidProviderInterface $uuidProvider, - PayPalConfigurationProviderInterface $payPalConfigurationProvider, - ChannelContextInterface $channelContext, - string $baseUrl, - int $requestTrialsLimit, - bool $loggingLevelIncreased = false + private ClientInterface|DeprecatedClientInterface $client, + private LoggerInterface $logger, + private UuidProviderInterface $uuidProvider, + private PayPalConfigurationProviderInterface $payPalConfigurationProvider, + private ChannelContextInterface $channelContext, + private string $baseUrl, + private int $requestTrialsLimit, + private bool $loggingLevelIncreased = false ) { - $this->client = $client; - $this->logger = $logger; - $this->uuidProvider = $uuidProvider; - $this->payPalConfigurationProvider = $payPalConfigurationProvider; - $this->channelContext = $channelContext; - $this->baseUrl = $baseUrl; - $this->requestTrialsLimit = $requestTrialsLimit; - $this->loggingLevelIncreased = $loggingLevelIncreased; } public function authorize(string $clientId, string $clientSecret): array