add auth sessions

This commit is contained in:
Yisroel Baum 2026-07-31 09:51:39 +03:00
parent a37c8da555
commit 34e26f81f5
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
9 changed files with 243 additions and 0 deletions

View file

@ -0,0 +1,41 @@
<?php
namespace App\Auth;
use App\User\User;
use DateTimeImmutable;
final readonly class Session
{
public function __construct(
private string $token,
private User $user,
private DateTimeImmutable $createdAt,
private DateTimeImmutable $expiresAt,
) {}
public function getToken(): string
{
return $this->token;
}
public function getUser(): User
{
return $this->user;
}
public function getCreatedAt(): DateTimeImmutable
{
return $this->createdAt;
}
public function getExpiresAt(): DateTimeImmutable
{
return $this->expiresAt;
}
public function isExpired(DateTimeImmutable $now): bool
{
return $now >= $this->expiresAt;
}
}