clientFactory = $clientFactory; } /** * @param \Psr\Http\Client\ClientInterface|null $httpClient * * @return ClientFactoryDependentService */ public function setHttpClient(?ClientInterface $httpClient): ClientFactoryDependentService { $this->httpClient = $httpClient; return $this; } /** * Returns true if API is available * * @param string $apiUrl * @param string $apiKey * * @return bool */ public function isApiAccessible(string $apiUrl, string $apiKey): bool { try { $client = $this->clientFactory->createClient($apiUrl, $apiKey); if (null !== $this->httpClient) { ReflectionUtils::setProperty( ReflectionUtils::getProperty($client, 'api'), 'httpClient', $this->httpClient ); } $client->api->apiVersions(); return true; } catch (Throwable $throwable) { return false; } } }