hanyuu/src/Users/UserInfo.php
2023-10-20 22:11:43 +00:00

75 lines
2 KiB
PHP

<?php
namespace Hanyuu\Users;
use Index\DateTime;
use Index\TimeZoneInfo;
use Index\Colour\Colour;
use Index\Colour\ColourRGB;
use Index\Data\IDbResult;
class UserInfo {
private string $id;
private string $name;
private string $country;
private Colour $colour;
private bool $isSuper;
private TimeZoneInfo $timeZone;
private DateTime $created;
private DateTime $updated;
private bool $isDeleted;
private DateTime $deleted;
public function __construct(IDbResult $result) {
$this->id = $result->getString(0);
$this->name = $result->getString(1);
$this->country = $result->getString(2);
$this->colour = $result->isNull(3) ? Colour::none() : ColourRGB::fromRawRGB($result->getInteger(3));
$this->isSuper = $result->getInteger(4) !== 0;
$this->timeZone = new TimeZoneInfo($result->getString(5));
$this->created = DateTime::fromUnixTimeSeconds($result->getInteger(6));
$this->updated = DateTime::fromUnixTimeSeconds($result->getInteger(7));
$this->isDeleted = !$result->isNull(8);
$this->deleted = DateTime::fromUnixTimeSeconds($result->isNull(8) ? 0 : $result->getInteger(8));
}
public function getId(): string {
return $this->id;
}
public function getName(): string {
return $this->name;
}
public function getCountryCode(): string {
return $this->country;
}
public function getColour(): Colour {
return $this->colour;
}
public function isSuper(): bool {
return $this->isSuper;
}
public function getTimeZone(): TimeZoneInfo {
return $this->timeZone;
}
public function getCreatedTime(): DateTime {
return $this->created;
}
public function getUpdatedTime(): DateTime {
return $this->updated;
}
public function isDeleted(): bool {
return $this->isDeleted;
}
public function getDeletedTime(): DateTime {
return $this->deleted;
}
}