82 lines
1.7 KiB
PHP
82 lines
1.7 KiB
PHP
<?php namespace RVR\PersistentData\Model;
|
|
|
|
use DateTime;
|
|
use SokoWeb\PersistentData\Model\Model;
|
|
|
|
class OAuthToken extends Model
|
|
{
|
|
protected static string $table = 'oauth_tokens';
|
|
|
|
protected static array $fields = ['session_id', 'created', 'expires'];
|
|
|
|
protected static array $relations = ['session' => OAuthSession::class];
|
|
|
|
private ?OAuthSession $session = null;
|
|
|
|
private ?int $sessionId = null;
|
|
|
|
private DateTime $created;
|
|
|
|
private DateTime $expires;
|
|
|
|
public function setSession(OAuthSession $session): void
|
|
{
|
|
$this->session = $session;
|
|
}
|
|
|
|
public function setSessionId(int $sessionId): void
|
|
{
|
|
$this->sessionId = $sessionId;
|
|
}
|
|
|
|
public function setCreatedDate(DateTime $created): void
|
|
{
|
|
$this->created = $created;
|
|
}
|
|
|
|
public function setExpiresDate(DateTime $expires): void
|
|
{
|
|
$this->expires = $expires;
|
|
}
|
|
|
|
public function setCreated(string $created): void
|
|
{
|
|
$this->created = new DateTime($created);
|
|
}
|
|
|
|
public function setExpires(string $expires): void
|
|
{
|
|
$this->expires = new DateTime($expires);
|
|
}
|
|
|
|
public function getSession(): ?OAuthSession
|
|
{
|
|
return $this->session;
|
|
}
|
|
|
|
public function getSessionId(): ?int
|
|
{
|
|
return $this->sessionId;
|
|
}
|
|
|
|
public function getCreatedDate(): DateTime
|
|
{
|
|
return $this->created;
|
|
}
|
|
|
|
public function getCreated(): string
|
|
{
|
|
return $this->created->format('Y-m-d H:i:s');
|
|
}
|
|
|
|
public function getExpiresDate(): DateTime
|
|
{
|
|
return $this->expires;
|
|
}
|
|
|
|
public function getExpires(): string
|
|
{
|
|
return $this->expires->format('Y-m-d H:i:s');
|
|
}
|
|
}
|