83 lines
2 KiB
PHP
83 lines
2 KiB
PHP
<?php
|
|
namespace Mince;
|
|
|
|
use Index\DateTime;
|
|
use Index\Data\IDbResult;
|
|
use Index\Net\IPAddress;
|
|
use Ramsey\Uuid\Uuid;
|
|
use Ramsey\Uuid\UuidInterface;
|
|
|
|
class AuthorisationInfo {
|
|
private string $id;
|
|
private string $uuid;
|
|
private string $addr;
|
|
private int $requested;
|
|
private ?int $granted;
|
|
private ?int $used;
|
|
|
|
public function __construct(IDbResult $result) {
|
|
$this->id = $result->getString(0);
|
|
$this->uuid = $result->getString(1);
|
|
$this->addr = $result->getString(2);
|
|
$this->requested = $result->getInteger(3);
|
|
$this->granted = $result->isNull(4) ? null : $result->getInteger(4);
|
|
$this->used = $result->isNull(5) ? null : $result->getInteger(5);
|
|
}
|
|
|
|
public function getId(): string {
|
|
return $this->id;
|
|
}
|
|
|
|
public function getUUIDRaw(): string {
|
|
return $this->uuid;
|
|
}
|
|
|
|
public function getUUID(): UuidInterface {
|
|
return Uuid::fromBytes($this->uuid);
|
|
}
|
|
|
|
public function getAddressRaw(): string {
|
|
return $this->addr;
|
|
}
|
|
|
|
public function getAddress(): IPAddress {
|
|
return IPAddress::parse($this->addr);
|
|
}
|
|
|
|
public function getRequestedTime(): int {
|
|
return $this->requested;
|
|
}
|
|
|
|
public function getRequestedAt(): DateTime {
|
|
return DateTime::fromUnixTimeSeconds($this->requested);
|
|
}
|
|
|
|
public function isPending(): bool {
|
|
return $this->granted === null;
|
|
}
|
|
|
|
public function isGranted(): bool {
|
|
return $this->granted !== null;
|
|
}
|
|
|
|
public function getGrantedTime(): ?int {
|
|
return $this->granted;
|
|
}
|
|
|
|
public function getGrantedAt(): ?DateTime {
|
|
return $this->granted === null ? null : DateTime::fromUnixTimeSeconds($this->granted);
|
|
}
|
|
|
|
public function isUsed(): bool {
|
|
return $this->used !== null;
|
|
}
|
|
|
|
public function getLastUsedTime(): ?int {
|
|
return $this->used;
|
|
}
|
|
|
|
public function getLastUsedAt(): ?DateTime {
|
|
return $this->used === null ? null : DateTime::fromUnixTimeSeconds($this->used);
|
|
}
|
|
}
|