public function cache($file, $content, $timestamp = null)
{
if (!($cachePath = $this->cachePath())) {
throw new JitException('Error, any cache path has been defined.');
}
$path = $cachePath . DS . ltrim(preg_replace('~:~', '', $file), DS);
if (!@file_exists(dirname($path))) {
mkdir(dirname($path), 0755, true);
}
if (file_put_contents($path, $content) === false) {
throw new JitException("Unable to create a cached file at `'{$file}'`.");
}
if ($timestamp) {
touch($path, $timestamp);
}
return $path;
}