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:----FdT4nRRgE7bQHe7wIQtsXS10b9c5ouJ00Noc6RLfPZ0bZ6xnX972IPNLXy+8fjNnFi2fY/c1YMe6IrMosDW44srLE1qeIHXL3vf6zy5mJtcjOjm6o+JKfbJdewgufXRjBv5tx5p3Ti62SWB/IyzwfkTs+phYtV2Xon1T7R+9yxBqvub/JlgGgk7MMpV76Tbx+ZSp5BhDDzDleX35pxWDsAbcURkNei7x57+e3IeZEkTHVpkIxD+XtQ8Ff6hO3Ih0L0m0XVkEiv1qT8BsL7c3loHMxNSaKa5oiUZsQP0xZwkjnjoyyg/8BntDmcGvYEjNpBKzpfW997oUq+/sY//Q5UtpePOr2bkeXTd6Pr0aB8o/0Y4duWD1hRY2hJXQ7woNEv9Uz8yQ2YfYhxBOv2IIwqcodp1yVCFDttX0MeDDkLO5+715WV2di2mVxPkB8DbQxHebc+wQtr+ErhOoLis6JtFi68rag6duPCO997AG/BYSetSO8kT6xoDCCOzHBDLEObyWk2ZOAlyJ3vayPu5CVyW+MRueVThyceWNHfjv6ClFg5ht3yYGnA6/rzLIf3oZO7g9jGjG30UBjPSEVcxjwjTRx1jMN5iqSL68ENaDmB4b2EZ83iZXELL6zqZHr6IEVyr0De0rJUdsJB6+VOzoVyTe3oluGed3l4PUP0ASPzU=----ATTACHMENT:----NjQ1NTE1NTA3NDMyOTk2NiAxMDg2NzQwNjUwOTUyMzAxIDY0Mzk2NzUzMjY3OTM2NTE=