public function __construct($apiKey = '', $fetcher = null, $cache = false, $seconds = 600)
{
if (!is_string($apiKey) || empty($apiKey)) {
// BC
$seconds = $cache !== false ? $cache : 600;
$cache = $fetcher !== null ? $fetcher : false;
$fetcher = $apiKey !== '' ? $apiKey : null;
} else {
$this->apiKey = $apiKey;
}
if ($cache !== false && !$cache instanceof AbstractCache) {
throw new \Exception('The cache class must implement the FetcherInterface!');
}
if (!is_numeric($seconds)) {
throw new \Exception('$seconds must be numeric.');
}
if (!isset($fetcher)) {
$fetcher = function_exists('curl_version') ? new CurlFetcher() : new FileGetContentsFetcher();
}
if ($seconds == 0) {
$cache = false;
}
$this->cache = $cache;
$this->seconds = $seconds;
$this->fetcher = $fetcher;
}