<commit_before><?php

/**
 * This file is part of florianeckerstorfer/gifstream.
 *
 * (c) 2013 <NAME> <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace florianeckerstorfer\gifstream;

/**
 * GifStreamCache
 *
 * @package   florianeckerstorfer/gifstream
 * @author    <NAME> <<EMAIL>>
 * @copyright 2013 <NAME>
 * @link      http://gifstream.florian.ec
 */
class GifStreamCache
{
    /** @var string */
    private $cacheDir;

    /** @var integer */
    private $cacheTime;

    /**
     * @param string $cacheDir
     */
    public function __construct($cacheDir, $cacheTime)
    {
        $this->cacheDir = $cacheDir;
        $this->cacheTime = $cacheTime;
    }

    /**
     * @param string $query
     *
     * @return boolean
     */
    public function has($query)
    {
        $file = $this->getCacheFile($query);

        return file_exists($file) && (filemtime($file) + $this->cacheTime) > time();
    }

    /**
     * @param string $query
     *
     * @return array
     */
    public function get($query)
    {
        return unserialize(file_get_contents($this->getCacheFile($query)));
    }

    /**
     * @param string $query
     * @param array  $content
     *
     * @return GifStreamCache
     */
    public function put($query, $content)
    {
        file_put_contents($this->getCacheFile($query), serialize($content));

        return $this;
    }

    /**
     * @param string $query
     *
     * @return string
     */
    protected function getCacheFile($query)
    {
        return sprintf('%s/%s.json', $this->cacheDir, urlencode($query));
    }
}
<commit_msg>Use lowercase cache key<commit_after><?php

/**
 * This file is part of florianeckerstorfer/gifstream.
 *
 * (c) 2013 <NAME> <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace florianeckerstorfer\gifstream;

/**
 * GifStreamCache
 *
 * @package   florianeckerstorfer/gifstream
 * @author    <NAME> <<EMAIL>>
 * @copyright 2013 <NAME>
 * @link      http://gifstream.florian.ec
 */
class GifStreamCache
{
    /** @var string */
    private $cacheDir;

    /** @var integer */
    private $cacheTime;

    /**
     * @param string $cacheDir
     */
    public function __construct($cacheDir, $cacheTime)
    {
        $this->cacheDir = $cacheDir;
        $this->cacheTime = $cacheTime;
    }

    /**
     * @param string $query
     *
     * @return boolean
     */
    public function has($query)
    {
        $file = $this->getCacheFile($query);

        return file_exists($file) && (filemtime($file) + $this->cacheTime) > time();
    }

    /**
     * @param string $query
     *
     * @return array
     */
    public function get($query)
    {
        return unserialize(file_get_contents($this->getCacheFile($query)));
    }

    /**
     * @param string $query
     * @param array  $content
     *
     * @return GifStreamCache
     */
    public function put($query, $content)
    {
        file_put_contents($this->getCacheFile($query), serialize($content));

        return $this;
    }

    /**
     * @param string $query
     *
     * @return string
     */
    protected function getCacheFile($query)
    {
        return sprintf('%s/%s.json', $this->cacheDir, urlencode(strtolower($query)));
    }
}

{'fraction_non_alphanumeric': 0.14344746162927982, 'fraction_numerical': 0.004722550177095631, 'mean_word_length': 2.3290766208251474, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 33, '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': '3627283', 'n_tokens_mistral': 1093, 'n_tokens_neox': 1056, 'n_words': 239}