Kahlan\Jit\Interceptor::cache PHP Method

cache() public method

Cache helper.
public cache ( string $file, string $content, $timestamp = null ) : string
$file string The source file path.
$content string The patched content to cache.
return string The patched file path or the cache path if called with no params.
    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;
    }