outputFileName = null === $outputFileName ? __DIR__ . Store::DATABASE_FILE : $outputFileName; /* * Defining HTTP adapter. * */ if (null === $httpAdapter) { $this->httpAdapter = new CurlAdapter(); return; } if (!class_exists($httpAdapter)) { throw new Exceptions\UpdateException(sprintf('Class "%s" is not defined', $httpAdapter)); } $this->httpAdapter = new $httpAdapter(); if (!($this->httpAdapter instanceof AdapterInterface)) { throw new Exceptions\UpdateException(sprintf('Class "%s" is implements adapter interface', $httpAdapter)); } } /** * Fetches actual Public Suffix List and writes obtained suffixes to target file. * * @return void * * @throws IOException */ public function run() { /* * Fetching Public Suffix List and parse suffixes. * */ $lines = $this->httpAdapter->get(Update::PUBLIC_SUFFIX_LIST_URL); $parser = new Parser($lines); $suffixes = $parser->parse(); /* * Write file with exclusive file write lock. * */ $handle = @fopen($this->outputFileName, 'w+'); if ($handle === false) { throw new Exceptions\IOException(error_get_last()['message']); } if (!flock($handle, LOCK_EX)) { throw new Exceptions\IOException(sprintf('Cannot obtain lock to output file (%s)', $this->outputFileName)); } $suffixFile = 'outputFileName)); } flock($handle, LOCK_UN); fclose($handle); } }