chore: complete update

This commit is contained in:
2025-07-17 16:24:20 +02:00
parent 899227b0a4
commit 64a7051137
1300 changed files with 85570 additions and 2756 deletions

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace App\Framework\Http\Cookies;
final readonly class Cookie
{
public function __construct(
public string $name,
public string $value,
public ?int $expires = null,
public string $path = '/',
public ?string $domain = '',
public bool $secure = false,
public bool $httpOnly = false,
public ?string $sameSite = 'Lax'
) {
}
public function toHeaderString(): string
{
$cookie = urlencode($this->name) . '=' . urlencode($this->value);
if ($this->expires !== null && $this->expires > 0) {
$cookie .= '; Expires=' . gmdate('D, d-M-Y H:i:s T', $this->expires);
}
if ($this->path) {
$cookie .= '; Path=' . $this->path;
}
if ($this->domain) {
$cookie .= '; Domain=' . $this->domain;
}
if ($this->secure) {
$cookie .= '; Secure';
}
if ($this->httpOnly) {
$cookie .= '; HttpOnly';
}
if ($this->sameSite) {
$cookie .= '; SameSite=' . $this->sameSite;
}
return $cookie;
}
}

View File

@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace App\Framework\Http\Cookies;
final readonly class Cookies
{
/** @var array<string, Cookie> */
private array $cookies;
public function __construct(Cookie ...$cookies)
{
foreach ($cookies as $cookie) {
$cookies[$cookie->name] = $cookie;
}
$this->cookies = $cookies;
}
public function get(string $name): ?Cookie
{
return $this->cookies[$name] ?? null;
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Framework\Http\Cookies;
enum SameSite: string
{
case Strict = 'Strict';
case Lax = 'Lax';
case None = 'None';
}