<commit_before><?php

/**
 * This file is part of the Minty templating library.
 * (c) <NAME> <<EMAIL>>
 *
 * For licensing information see the LICENSE file.
 */

namespace Minty;

use Minty\Compiler\TemplateCacheInterface;

class FileSystemCache implements TemplateCacheInterface
{
    private $directory;

    public function __construct($cacheDir)
    {
        $this->directory = $cacheDir;
    }

    public function load($file)
    {
        includeFile($this->getCachePath($file));
    }

    public function save($file, $compiled)
    {
        $destination = $this->getCachePath($file);

        $cacheDir = dirname($destination);
        if (!is_dir($cacheDir)) {
            mkdir($cacheDir, 0777, true);
        }
        file_put_contents($destination, $compiled);
    }

    public function getCreatedTime($file)
    {
        $cachePath = $this->getCachePath($file);

        if (!is_file($cachePath)) {
            return 0;
        }

        return filemtime($cachePath);
    }

    public function exists($file)
    {
        return is_file($this->getCachePath($file));
    }

    private function getCachePath($file)
    {
        return $this->directory . '/' . $file . '.php';
    }
}

function includeFile($file)
{
    include $file;
}
<commit_msg>Update FileSystemCache.php<commit_after><?php

/**
 * This file is part of the Minty templating library.
 * (c) <NAME> <<EMAIL>>
 *
 * For licensing information see the LICENSE file.
 */

namespace Minty;

use Minty\TemplateCacheInterface;

class FileSystemCache implements TemplateCacheInterface
{
    private $directory;

    public function __construct($cacheDir)
    {
        $this->directory = $cacheDir;
    }

    public function load($file)
    {
        includeFile($this->getCachePath($file));
    }

    public function save($file, $compiled)
    {
        $destination = $this->getCachePath($file);

        $cacheDir = dirname($destination);
        if (!is_dir($cacheDir)) {
            mkdir($cacheDir, 0777, true);
        }
        file_put_contents($destination, $compiled);
    }

    public function getCreatedTime($file)
    {
        $cachePath = $this->getCachePath($file);

        if (!is_file($cachePath)) {
            return 0;
        }

        return filemtime($cachePath);
    }

    public function exists($file)
    {
        return is_file($this->getCachePath($file));
    }

    private function getCachePath($file)
    {
        return $this->directory . '/' . $file . '.php';
    }
}

function includeFile($file)
{
    include $file;
}

{'fraction_non_alphanumeric': 0.13040062843676356, 'fraction_numerical': 0.003927729772191673, 'mean_word_length': 2.5375, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '736437', 'n_tokens_mistral': 780, 'n_tokens_neox': 743, 'n_words': 163}