<?php

namespace App\Security;

use Symfony\Component\HttpFoundation\Cookie;

final class DeviceCookieFactory
{
    public const NAME = '__Host-device_session';

    public function create(string $token, \DateTimeImmutable $expiresAt): Cookie
    {
        return Cookie::create(self::NAME)
            ->withValue($token)
            ->withExpires($expiresAt)
            ->withPath('/')
            ->withSecure(true)
            ->withHttpOnly(true)
            ->withSameSite(Cookie::SAMESITE_STRICT);
    }

    public function expire(): Cookie
    {
        return $this->create('', new \DateTimeImmutable('-1 year'));
    }
}
