35 lines
709 B
PHP
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.');
|
|
}
|
|
}
|