mince/src/VerificationInfo.php
2024-02-21 16:08:45 +00:00

60 lines
1.4 KiB
PHP

<?php
namespace Mince;
use Index\DateTime;
use Index\Data\IDbResult;
use Index\Net\IPAddress;
use Ramsey\Uuid\{Uuid,UuidInterface};
class VerificationInfo {
public function __construct(
private string $code,
private string $uuid,
private string $name,
private string $addr,
private int $created,
) {}
public static function fromResult(IDbResult $result): self {
return new VerificationInfo(
code: $result->getString(0),
uuid: $result->getString(1),
name: $result->getString(2),
addr: $result->getString(3),
created: $result->getInteger(4),
);
}
public function getCode(): string {
return $this->code;
}
public function getUUIDRaw(): string {
return $this->uuid;
}
public function getUUID(): UuidInterface {
return Uuid::fromBytes($this->uuid);
}
public function getName(): string {
return $this->name;
}
public function getAddressRaw(): string {
return $this->addr;
}
public function getAddress(): IPAddress {
return IPAddress::parse($this->addr);
}
public function getCreatedTime(): int {
return $this->created;
}
public function getCreatedAt(): DateTime {
return DateTime::fromUnixTimeSeconds($this->created);
}
}