public function __construct($applicationID, $apiKey, $hostsArray = null, $options = array())
{
if (!function_exists('curl_init')) {
throw new \Exception('AlgoliaSearch requires the CURL PHP extension.');
}
if (!function_exists('json_decode')) {
throw new \Exception('AlgoliaSearch requires the JSON PHP extension.');
}
$this->caInfoPath = __DIR__ . '/../../resources/ca-bundle.crt';
foreach ($options as $option => $value) {
switch ($option) {
case self::CAINFO:
$this->caInfoPath = $value;
break;
case self::CURLOPT:
$this->curlOptions = $this->checkCurlOptions($value);
break;
case self::PLACES_ENABLED:
$this->placesEnabled = (bool) $value;
break;
default:
throw new \Exception('Unknown option: ' . $option);
}
}
$this->context = new ClientContext($applicationID, $apiKey, $hostsArray, $this->placesEnabled);
}