mince/src/VerificationInfo.php

60 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2023-08-22 23:47:37 +00:00
<?php
namespace Mince;
use Index\DateTime;
use Index\Data\IDbResult;
use Index\Net\IPAddress;
2024-02-21 16:08:45 +00:00
use Ramsey\Uuid\{Uuid,UuidInterface};
2023-08-22 23:47:37 +00:00
class VerificationInfo {
2024-02-21 16:08:45 +00:00
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),
);
2023-08-22 23:47:37 +00:00
}
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);
}
}