AlgoliaSearch\ClientContext::__construct PHP Method

__construct() public method

ClientContext constructor.
public __construct ( string $applicationID, string $apiKey, array $hostsArray, boolean $placesEnabled = false )
$applicationID string
$apiKey string
$hostsArray array
$placesEnabled boolean
    public function __construct($applicationID, $apiKey, $hostsArray, $placesEnabled = false)
    {
        // connect timeout of 2s by default
        $this->connectTimeout = 2;
        // global timeout of 30s by default
        $this->readTimeout = 30;
        // search timeout of 5s by default
        $this->searchTimeout = 5;
        $this->applicationID = $applicationID;
        $this->apiKey = $apiKey;
        $this->readHostsArray = $hostsArray;
        $this->writeHostsArray = $hostsArray;
        if ($this->readHostsArray == null || count($this->readHostsArray) == 0) {
            $this->readHostsArray = $this->getDefaultReadHosts($placesEnabled);
            $this->writeHostsArray = $this->getDefaultWriteHosts();
        }
        if ($this->applicationID == null || mb_strlen($this->applicationID) == 0) {
            throw new Exception('AlgoliaSearch requires an applicationID.');
        }
        if ($this->apiKey == null || mb_strlen($this->apiKey) == 0) {
            throw new Exception('AlgoliaSearch requires an apiKey.');
        }
        $this->curlMHandle = null;
        $this->adminAPIKey = null;
        $this->endUserIP = null;
        $this->algoliaUserToken = null;
        $this->rateLimitAPIKey = null;
        $this->headers = array();
    }