<?php

/*
 * This file is part of the AuthStack project.
 *
 * (c) Buckhill Ltd <development@buckhill.co.uk>
 *
 * This source file is subject to the Buckhill license that is bundled
 * with this source code in the file LICENSE.
 */

namespace AuthStack\Session\Storage\Serialization;

use Symfony\Component\HttpFoundation\Cookie;

class Record
{
    protected $name;
    protected $value;

    public function __construct($name, $value)
    {
        $this->name = $name;
        $this->value = $value;
    }


    /**
     * @return mixed
     */
    public function getName()
    {
        return $this->name;
    }


    /**
     * @return mixed
     */
    public function getValue()
    {
        return $this->value;
    }


    /**
     * @param \DateTime $expire
     * @param string    $domain
     * @param bool|true $secure
     * @param bool|true $httpOnly
     *
     * @return Cookie
     */
    public function toCookie(\DateTime $expire, $domain = '', $secure = true, $httpOnly = true)
    {
        return new Cookie($this->getName(), $this->getValue(), $expire, '/', $domain, $secure, $httpOnly);
    }
}