|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / a / home / dev2.destoffenstraat.com / vendor / jms / metadata / src / Metadata / Cache / |
Filename | /home/a/home/dev2.destoffenstraat.com/vendor/jms/metadata/src/Metadata/Cache/FileCache.php |
Size | 2.37 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 21-Aug-2025 12:26 |
Last modified | 26-Oct-2018 14:40 |
Last accessed | 23-Aug-2025 00:36 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
namespace Metadata\Cache;
use Metadata\ClassMetadata;
class FileCache implements CacheInterface
{
private $dir;
public function __construct($dir)
{
if (!is_dir($dir)) {
throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir));
}
$this->dir = rtrim($dir, '\\/');
}
/**
* {@inheritDoc}
*/
public function loadClassMetadataFromCache(\ReflectionClass $class)
{
$path = $this->dir.'/'.strtr($class->name, '\\', '-').'.cache.php';
if (!file_exists($path)) {
return null;
}
return include $path;
}
/**
* {@inheritDoc}
*/
public function putClassMetadataInCache(ClassMetadata $metadata)
{
if (!is_writable($this->dir)) {
throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable.', $this->dir));
}
$path = $this->dir.'/'.strtr($metadata->name, '\\', '-').'.cache.php';
$tmpFile = tempnam($this->dir, 'metadata-cache');
file_put_contents($tmpFile, '<?php return unserialize('.var_export(serialize($metadata), true).');');
// Let's not break filesystems which do not support chmod.
@chmod($tmpFile, 0666 & ~umask());
$this->renameFile($tmpFile, $path);
}
/**
* Renames a file with fallback for windows
*
* @param string $source
* @param string $target
*/
private function renameFile($source, $target) {
if (false === @rename($source, $target)) {
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
if (false === copy($source, $target)) {
throw new \RuntimeException(sprintf('(WIN) Could not write new cache file to %s.', $target));
}
if (false === unlink($source)) {
throw new \RuntimeException(sprintf('(WIN) Could not delete temp cache file to %s.', $source));
}
} else {
throw new \RuntimeException(sprintf('Could not write new cache file to %s.', $target));
}
}
}
/**
* {@inheritDoc}
*/
public function evictClassMetadataFromCache(\ReflectionClass $class)
{
$path = $this->dir.'/'.strtr($class->name, '\\', '-').'.cache.php';
if (file_exists($path)) {
unlink($path);
}
}
}
namespace Metadata\Cache;
use Metadata\ClassMetadata;
class FileCache implements CacheInterface
{
private $dir;
public function __construct($dir)
{
if (!is_dir($dir)) {
throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir));
}
$this->dir = rtrim($dir, '\\/');
}
/**
* {@inheritDoc}
*/
public function loadClassMetadataFromCache(\ReflectionClass $class)
{
$path = $this->dir.'/'.strtr($class->name, '\\', '-').'.cache.php';
if (!file_exists($path)) {
return null;
}
return include $path;
}
/**
* {@inheritDoc}
*/
public function putClassMetadataInCache(ClassMetadata $metadata)
{
if (!is_writable($this->dir)) {
throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable.', $this->dir));
}
$path = $this->dir.'/'.strtr($metadata->name, '\\', '-').'.cache.php';
$tmpFile = tempnam($this->dir, 'metadata-cache');
file_put_contents($tmpFile, '<?php return unserialize('.var_export(serialize($metadata), true).');');
// Let's not break filesystems which do not support chmod.
@chmod($tmpFile, 0666 & ~umask());
$this->renameFile($tmpFile, $path);
}
/**
* Renames a file with fallback for windows
*
* @param string $source
* @param string $target
*/
private function renameFile($source, $target) {
if (false === @rename($source, $target)) {
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
if (false === copy($source, $target)) {
throw new \RuntimeException(sprintf('(WIN) Could not write new cache file to %s.', $target));
}
if (false === unlink($source)) {
throw new \RuntimeException(sprintf('(WIN) Could not delete temp cache file to %s.', $source));
}
} else {
throw new \RuntimeException(sprintf('Could not write new cache file to %s.', $target));
}
}
}
/**
* {@inheritDoc}
*/
public function evictClassMetadataFromCache(\ReflectionClass $class)
{
$path = $this->dir.'/'.strtr($class->name, '\\', '-').'.cache.php';
if (file_exists($path)) {
unlink($path);
}
}
}