Files
drmaterac.pl/modules/empikmarketplace/src/Factory/HttpClientsFactory.php
2025-01-06 20:47:25 +01:00

35 lines
709 B
PHP

<?php
namespace Empik\Marketplace\Factory;
use Empik\Marketplace\API\HttpClientInterface;
use Empik\Marketplace\API\HttpCurlClient;
use Exception;
class HttpClientsFactory
{
/**
* @param null $handler
* @return HttpClientInterface
* @throws Exception
*/
public static function createHttpClient($handler = null)
{
return self::detectDefaultClient();
}
/**
* @return HttpClientInterface
* @throws Exception
*/
private static function detectDefaultClient()
{
if (function_exists('curl_version')) {
return new HttpCurlClient();
}
throw new Exception('Unable to detect default HTTP client.');
}
}