<commit_before><?php
/**
 *
 */

namespace Mvc5\Cookie\Config;

use Mvc5\Arg;

trait PHPCookies
{
    /**
     *
     */
    use Cookies;

    /**
     * @param array $cookies
     * @param array $defaults
     */
    function __construct(array $cookies = [], array $defaults = [])
    {
        $this->config = $cookies ?? $_COOKIE;
        $this->defaults = $defaults + $this->defaults;
    }

    /**
     * @param string $name
     * @param string $value
     * @param int|null|string $expire
     * @param null|string $path
     * @param null|string $domain
     * @param bool|null $secure
     * @param bool|null $httponly
     * @return mixed
     */
    protected static function params($name, $value = '', $expire = null, string $path = null,
                                     string $domain = null, bool $secure = null, bool $httponly = null)
    {
        return [
            (string) $name, (string) $value, (int) (is_string($expire) ? strtotime($expire) : $expire),
            $path ?? Arg::SEPARATOR, (string) $domain, $secure ?? false, $httponly ?? true
        ];
    }

    /**
     * @param array $cookie
     * @return bool
     */
    static function send(array $cookie)
    {
        return setcookie(...static::params(...array_values($cookie)));
    }

    /**
     * @param string $name
     * @param string $value
     * @param int|null|string $expire
     * @param null|string $path
     * @param null|string $domain
     * @param bool|null $secure
     * @param bool|null $httponly
     * @return mixed
     */
    function set($name, $value = '', $expire = null,<commit_msg>[fix] default config uses super global cookie<commit_after><?php
/**
 *
 */

namespace Mvc5\Cookie\Config;

trait PHPCookies
{
    /**
     *
     */
    use Cookies;

    /**
     * @param array|null $cookies
     * @param array $defaults
     */
    function __construct(array $cookies = null, array $defaults = [])
    {
        $this->config = $cookies ?? $_COOKIE;
        $this->defaults = $defaults + $this->defaults;
    }

    /**
     * @param string $name
     * @param string $value
     * @param int|null|string $expire
     * @param null|string $path
     * @param null|string $domain
     * @param bool|null $secure
     * @param bool|null $httponly
     * @return mixed
     */
    protected static function params($name, $value = '', $expire = null, string $path = null,
                                     string $domain = null, bool $secure = null, bool $httponly = null)
    {
        return [
            (string) $name, (string) $value, (int) (is_string($expire) ? strtotime($expire) : $expire),
            $path ?? '/', (string) $domain, $secure ?? false, $httponly ?? true
        ];
    }

    /**
     * @param array $cookie
     * @return bool
     */
    static function send(array $cookie)
    {
        return setcookie(...static::params(...array_values($cookie)));
    }

    /**
     * @param string $name
     * @param string $value
     * @param int|null|string $expire
     * @param null|string $path
     * @param null|string $domain
     * @param bool|null $secure
     * @param bool|null $httponly
     * @return mixed
     */
    function set($name, $value = '', $expire = null,
{'fraction_non_alphanumeric': 0.15131782945736433, 'fraction_numerical': 0.0009302325581395349, 'mean_word_length': 2.1078998073217727, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6866075', 'n_tokens_mistral': 1011, 'n_tokens_neox': 993, 'n_words': 251}