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

namespace Mvc5\Cookie\Config;

use Mvc5\Arg;

trait Cookies
{
    /**
     * @var array
     */
    protected $config = [];

    /**
     * @var array
     */
    protected $defaults = [
        Arg::EXPIRE    => 0,
        Arg::PATH      => '/',
        Arg::DOMAIN    => '',
        Arg::SECURE    => false,
        Arg::HTTP_ONLY => true
    ];

    /**
     * @param array $cookies
     * @param array $defaults
     */
    function __construct(array $cookies = [], array $defaults = [])
    {
        $this->config = $cookies;
        $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 array
     */
    protected function cookie($name, $value, $expire = null,
                              string $path = null, string $domain = null, bool $secure = null, bool $httponly = null)
    {
        return [
            Arg::NAME => (string) $name,
            Arg::VALUE => (string) $value,
            Arg::EXPIRE => $expire ?? $this->defaults[Arg::EXPIRE],
            Arg::PATH => $path ?? $this->defaults[Arg::PATH],
            Arg::DOMAIN => $domain ?? $this->defaults[Arg::DOMAIN],
            Arg::SECURE => $secure ?? $this->defaults[Arg::SECURE],<commit_msg>expire is string or int<commit_after><?php
/**
 *
 */

namespace Mvc5\Cookie\Config;

use Mvc5\Arg;

trait Cookies
{
    /**
     * @var array
     */
    protected $config = [];

    /**
     * @var array
     */
    protected $defaults = [
        Arg::EXPIRE    => 0,
        Arg::PATH      => '/',
        Arg::DOMAIN    => '',
        Arg::SECURE    => false,
        Arg::HTTP_ONLY => true
    ];

    /**
     * @param array $cookies
     * @param array $defaults
     */
    function __construct(array $cookies = [], array $defaults = [])
    {
        $this->config = $cookies;
        $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 array
     */
    protected function cookie($name, $value, $expire = null,
                              string $path = null, string $domain = null, bool $secure = null, bool $httponly = null)
    {
        return [
            Arg::NAME => (string) $name,
            Arg::VALUE => (string) $value,
            Arg::EXPIRE => is_string($expire ?? $expire = $this->defaults[Arg::EXPIRE]) ? $expire : (int) $expire,
            Arg::PATH => $path ?? $this->defaults[Arg::PATH],
            Arg::DOMAIN => $domain ?? $this->defaults[Arg::DOMAIN],
            Arg::SECURE => $secure ?? $this->defaults[Arg::SECURE],
{'fraction_non_alphanumeric': 0.1668355285376562, 'fraction_numerical': 0.002026342451874367, 'mean_word_length': 1.9443339960238568, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, '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': '6117907', 'n_tokens_mistral': 923, 'n_tokens_neox': 912, 'n_words': 205}