* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Core\Util\Url; /** * Class UrlFileChecker */ final class UrlFileChecker implements UrlFileCheckerInterface { /** * @var string */ private $fileDir; /** * @param string $fileDir */ public function __construct($fileDir) { $this->fileDir = $fileDir; } /** * @return bool */ public function isHtaccessFileWritable() { return $this->isFileWritable('.htaccess'); } /** * @return bool */ public function isRobotsFileWritable() { return $this->isFileWritable('robots.txt'); } /** * @param string $fileName * * @return bool */ private function isFileWritable($fileName) { $filePath = $this->fileDir . DIRECTORY_SEPARATOR . $fileName; if (file_exists($filePath)) { return is_writable($filePath); } return is_writable($this->fileDir); } }