<commit_before><?php namespace CodeZero\Cookie; 

class VanillaCookieCore implements CookieCore
{
    /**
     * Cookies
     *
     * @var array
     */
    private $cookies;

    /**
     * Create a new instance of VanillaCookieCore
     *
     * @param array $cookies
     */
    public function __construct(array &$cookies = null)
    {
        if ($cookies) {
            $this->cookies = & $cookies;
        } else {
            $this->cookies = & $_COOKIE;
        }
    }

    /**
     * Get the value of a cookie
     *
     * @param string $name
     *
     * @return null|string
     */
    public function get($name)
    {
        if ( ! isset($this->cookies[$name])) {
            return null;
        }

        return $this->cookies[$name];
    }

    /**
     * Set a cookie
     *
     * @param string $name
     * @param string $value
     * @param int $expire
     * @param string $path
     * @param string $domain
     * @param bool $secure
     * @param bool $httponly
     *
     * @return bool
     */
    public function set($name, $value, $expire, $path = null, $domain = null, $secure = null, $httponly = null)
    {
        return setcookie($name, $value, $expire, $path, $domain, $secure, $httponly);
    }

    /**
     * Delete a cookie
     *
     * @param string $name
     *
     * @return bool
     */
    public function delete($name)
    {
        if (isset($this->cookies[$name])) {
            unset($this->cookies[$name]);

            return $this->set($name, null, -1);
        }

        return true;
    }
}<commit_msg>Extract exists() method and refactor delete() method in VanillaCookieCore<commit_after><?php namespace CodeZero\Cookie; 

class VanillaCookieCore implements CookieCore
{
    /**
     * Cookies
     *
     * @var array
     */
    private $cookies;

    /**
     * Create a new instance of VanillaCookieCore
     *
     * @param array $cookies
     */
    public function __construct(array &$cookies = null)
    {
        if ($cookies) {
            $this->cookies = & $cookies;
        } else {
            $this->cookies = & $_COOKIE;
        }
    }

    /**
     * Get the value of a cookie
     *
     * @param string $name
     *
     * @return null|string
     */
    public function get($name)
    {
        if ( ! $this->exists($name)) {
            return null;
        }

        return $this->cookies[$name];
    }

    /**
     * Set a cookie
     *
     * @param string $name
     * @param string $value
     * @param int $expire
     * @param string $path
     * @param string $domain
     * @param bool $secure
     * @param bool $httponly
     *
     * @return bool
     */
    public function set($name, $value, $expire, $path = null, $domain = null, $secure = null, $httponly = null)
    {
        return setcookie($name, $value, $expire, $path, $domain, $secure, $httponly);
    }

    /**
     * Delete a cookie
     *
     * @param string $name
     *
     * @return bool
     */
    public function delete($name)
    {
        if ( ! $this->exists($name)) {
            return true;
        }

        unset($this->cookies[$name]);

        return $this->set($name, null, -1);
    }

    /**
     * Check if a cookie exists
     *
     * @param string $name
     *
     * @return bool
     */
    private function exists($name)
    {
        return isset($this->cookies[$name]);
    }
}
{'fraction_non_alphanumeric': 0.13645802432512608, 'fraction_numerical': 0.0005932957579353308, 'mean_word_length': 1.6783161239078634, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, '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': '2941748', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1035, 'n_words': 263}