protected function doSet($id, $data, $ttl = Cache::TTL_NO_EXPIRY)
{
if ($ttl > 0) {
$ttl = time() + $ttl;
}
// if we have an array containing objects - we will have a problem.
if (is_object($data) && !method_exists($data, '__set_state')) {
throw new CacheException("Invalid argument given, PhpFileAdapter only allows objects that implement __set_state() " . "and fully support var_export().");
}
$fileName = $this->getFilename($id);
$filePath = pathinfo($fileName, PATHINFO_DIRNAME);
if (!is_dir($filePath)) {
mkdir($filePath, 0777, true);
}
$cacheEntry = ['ttl' => $ttl, 'data' => $data];
$cacheEntry = var_export($cacheEntry, true);
$code = sprintf('<?php return %s;', $cacheEntry);
return $this->writeFile($fileName, $code);
}