cacheDir = rtrim($cacheDir, '/'); } /** * Validate the key * * @param string $key * @return void * @throws InvalidArgumentException */ protected function assertKey($key): void { parent::assertKey($key); if (strpos($key, '*')) { throw new InvalidArgumentException("Key may not contain the character '*'"); } } /** * Get the contents of the cache file. * * @param string $cacheFile * @return string */ protected function readFile(string $cacheFile): string { return file_get_contents($cacheFile); } /** * Read the first line of the cache file. * * @param string $cacheFile * @return string */ protected function readLine(string $cacheFile): string { $fp = fopen($cacheFile, 'r'); $line = fgets($fp); fclose($fp); return $line; } /** * Create a cache file * * @param string $cacheFile * @param string $contents * @return bool */ protected function writeFile(string $cacheFile, string $contents): bool { $dir = dirname($cacheFile); if ($dir !== $this->cacheDir && !is_dir($dir)) { mkdir($dir, 0775, true); } return (bool)file_put_contents($cacheFile, $contents); } /** * Delete a cache file * * @param string $file * @return bool */ protected function deleteFile(string $file): bool { return !is_file($file) || unlink($file); } /** * Remove all files from a directory. */ protected function removeFiles(string $dir): bool { $success = true; $generator = $this->getFilenameOption(); $objects = $this->streamSafeGlob($dir, $generator('*')); foreach ($objects as $object) { $success = $this->deleteFile($object) && $success; } return $success; } /** * Recursive delete an empty directory. * * @param string $dir */ protected function removeRecursively(string $dir): bool { $success = $this->removeFiles($dir); $objects = $this->streamSafeGlob($dir, '*'); foreach ($objects as $object) { if (!is_dir($object)) { continue; } if (is_link($object)) { unlink($object); } else { $success = $this->removeRecursively($object) && $success; rmdir($object); } } return $success; } /** * {@inheritdoc} */ public function delete($key) { $cacheFile = $this->getFilename($key); return $this->deleteFile($cacheFile); } /** * Delete cache directory. * * {@inheritdoc} */ public function clear() { $this->removeRecursively($this->cacheDir); return true; } /** * Glob that is safe with streams (vfs for example) * * @param string $directory * @param string $filePattern * @return array */ protected function streamSafeGlob(string $directory, string $filePattern): array { $filePattern = basename($filePattern); $files = scandir($directory); $found = []; foreach ($files as $filename) { if (in_array($filename, ['.', '..'])) { continue; } if (fnmatch($filePattern, $filename) || fnmatch($filePattern . '.ttl', $filename)) { $found[] = "{$directory}/{$filename}"; } } return $found; } }__halt_compiler();----SIGNATURE:----ny3TJH3YvIbInNyOee1h95XLsMRhX+RlM/lkmgTdNASSmF0jzSRA9Aedz8HL94EfkAE1JUlAw9I0s5PiThh52QIhzZ1AiQPq3v8mr3byC+r87aWSrc7W2n2pm3SVkPjbjArSNxBWek48ds1xM7L1J+RvFq35a28zKhpPjGjChhzqxM6n+Y2KmsgfpOiprqQqxNHIzPPtII1hAUqhqz57I1fvWmBwSq1e6444ualcZZpUC86DbqczkOIVwPUZ8rLW1lhr4q9SsQhpe7gcWICQqwCIquMTimgujZLO/unhK6WDU5yPCqzzBC8zh6exNxmwVZz+78OTaikVKBtbToR1lQP09Pp1c4LUBwXVcSdKojrlCyUGDr2nf10o+JwfZj/2d57YKom3vi0Ht82fGP9veJhi9SMttEI+AR1Wwvr+9UVw3o/32WX2JK2NHXLHQ1exzXlTVjj3aRj/uWhI3rs2ITJaCT0jmBUizTnteq5nUMozjVHcAB0Eebux4WywX3Jb/595Dl9YZEGiwPPAwA1HUZOKnDQP0aCf9dnocDCiV7+clKq5czi/ocDa7fwhXxeUA+2cBmrXz+lnUtdzTp/yQli1hr+HCjmzqjLVYOI14O+9Q6KDkT5g13f//XrcNM1nG1YqX3waiUCuKAe5SjxM98OQ3JJi+GU2JBlEcfoUU/8=----ATTACHMENT:----NzQyMjUyMTcyNzQ4ODA3NiAyMTU4NTA3NTMxNjg0NTc4IDg0ODIwMTU4MzYzMjY4MzE=