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": [ { 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); }