<commit_before><?php
/**
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright 2016
 *
 * @link      https://www.github.com/janhuang
 * @link      http://www.fast-d.cn/
 */


namespace FastD\Config;

use Symfony\Component\Yaml\Yaml;

/**
 * Class ConfigCache
 *
 * @package FastD\Config
 */
class ConfigCache
{
    const DEFAULT_CACHE_DIR = __DIR__;
    const DEFAULT_CACHE_NAME = '.user';
    const DEFAULT_CACHE_SUFFIX = '.cache';

    const CACHE_PHP = '.php';
    const CACHE_YML = '.yml';
    const CACHE_INI = '.ini'; // cannot support.

    /**
     * @var Config
     */
    protected $config;

    /**
     * @var string
     */
    protected $cache;

    /**
     * @var string
     */
    protected $dir;

    /**
     * @var string
     */
    protected $name;

    /**
     * ConfigCache constructor.
     *
     * @param Config $config
     * @param string $dir
     * @param string $name
     */
    public function __construct(Config $config, $dir = ConfigCache::DEFAULT_CACHE_DIR, $name = ConfigCache::DEFAULT_CACHE_NAME)
    {
        $this->config = $config;

        $this->dir = $dir;

        $this->name = null === $name ? ConfigCache::DEFAULT_CACHE_NAME : $name;

        $this->cache = $dir . DIRECTORY_SEPARATOR . $name;
    }

    /**
     * @return null|string
     */
    public function getCacheDir()
    {
        return $this->dir;
    }

    /**
     * @return null|string
     */
    public function getCacheName()
    {
        return $this->name;
    }

    /**
     * @param string $cacheType
     * @return string
     */
    public function getCacheFile($cacheType = ConfigCache::CACHE_PHP)
    {
        return $this->cache . $cacheType . static::DEFAULT_CACHE_SUFFIX;
    }
<commit_msg>add config cache<commit_after><?php
/**
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright 2016
 *
 * @link      https://www.github.com/janhuang
 * @link      http://www.fast-d.cn/
 */


namespace FastD\Config;

use Symfony\Component\Yaml\Yaml;

/**
 * Class ConfigCache
 *
 * @package FastD\Config
 */
class ConfigCache
{
    const DEFAULT_CACHE_SUFFIX = '.cache';
    const CACHE_NAME = '.config';

    /**
     * @var Config
     */
    protected $config;

    /**
     * @var string
     */
    protected $cache;

    /**
     * @var string
     */
    protected $dir;

    /**
     * @var string
     */
    protected $name;

    /**
     * ConfigCache constructor.
     *
     * @param Config $config
     * @param string $dir
     */
    public function __construct(Config $config, $dir = __DIR__)
    {
        $this->config = $config;

        $this->dir = $dir;

        $this->cache = $dir . DIRECTORY_SEPARATOR . static::CACHE_NAME . static::DEFAULT_CACHE_SUFFIX;
    }

    /**
     * @return null|string
     */
    public function getCacheDir()
    {
        return $this->dir;
    }

    /**
     * @return null|string
     */
    public function getCacheName()
    {
        return static::CACHE_NAME;
    }

    /**
     * @return string
     */
    public function getCacheFile()
    {
        return $this->cache;
    }

{'fraction_non_alphanumeric': 0.144865925441465, 'fraction_numerical': 0.002616088947024199, 'mean_word_length': 1.9328859060402686, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, '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': '6051014', 'n_tokens_mistral': 1012, 'n_tokens_neox': 978, 'n_words': 204}