40 lines
739 B
PHP
40 lines
739 B
PHP
<?php
|
|
|
|
namespace App\Auth;
|
|
|
|
use DateTimeImmutable;
|
|
|
|
class Session
|
|
{
|
|
public function __construct(
|
|
private string $token,
|
|
private int $userId,
|
|
private DateTimeImmutable $createdAt,
|
|
private DateTimeImmutable $expiresAt,
|
|
) {}
|
|
|
|
public function getToken(): string
|
|
{
|
|
return $this->token;
|
|
}
|
|
|
|
public function getUserId(): int
|
|
{
|
|
return $this->userId;
|
|
}
|
|
|
|
public function getCreatedAt(): DateTimeImmutable
|
|
{
|
|
return $this->createdAt;
|
|
}
|
|
|
|
public function getExpiresAt(): DateTimeImmutable
|
|
{
|
|
return $this->expiresAt;
|
|
}
|
|
|
|
public function isExpired(DateTimeImmutable $now): bool
|
|
{
|
|
return $now >= $this->expiresAt;
|
|
}
|
|
}
|