From 9e569cc61df41b518fb21fb44cb05322c4514f76 Mon Sep 17 00:00:00 2001 From: Liakhovskyi Vladyslav Date: Fri, 8 Mar 2024 22:25:10 +0200 Subject: [PATCH 1/2] Replace php cs fixer with a shim version. --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 20d7012..f6a300c 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ "require-dev": { "jane-php/open-api-3": "^7.6", "phpstan/phpstan": "^1.10", - "friendsofphp/php-cs-fixer": "*" + "php-cs-fixer/shim": "^3.51" + }, "authors": [ { From 152b422c8a88603225b65a4d171aaee2f69c7245 Mon Sep 17 00:00:00 2001 From: Liakhovskyi Vladyslav Date: Fri, 8 Mar 2024 22:27:07 +0200 Subject: [PATCH 2/2] Allow a custom client to be passed. --- src/ClientFactory.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ClientFactory.php b/src/ClientFactory.php index 6e2ac85..382b330 100644 --- a/src/ClientFactory.php +++ b/src/ClientFactory.php @@ -7,19 +7,22 @@ use GuzzleHttp\Psr7\Uri; use Http\Client\Common\Plugin\AddHostPlugin; use Http\Client\Common\PluginClient; +use Http\Client\HttpAsyncClient; use Http\Discovery\Psr18ClientDiscovery; use Jane\Component\OpenApiRuntime\Client\Plugin\AuthenticationRegistry; +use Psr\Http\Client\ClientInterface; final readonly class ClientFactory { - public static function createClient(string $token = null): Client + public static function createClient(string $token = null, + HttpAsyncClient|ClientInterface $client = null): Client { $plugins = []; if (null !== $token) { $plugins[] = new AuthenticationRegistry([new BearerAuthentication($token)]); } $plugins[] = new AddHostPlugin(new Uri('https://api.checkbox.in.ua'), ['replace' => true]); - $pluginClient = new PluginClient(Psr18ClientDiscovery::find(), $plugins); + $pluginClient = new PluginClient($client??Psr18ClientDiscovery::find(), $plugins); return Client::create($pluginClient); }