76 lines
2 KiB
PHP
76 lines
2 KiB
PHP
<?php
|
|
namespace Hanyuu\Users\Db;
|
|
|
|
use Index\DateTime;
|
|
use Index\TimeZoneInfo;
|
|
use Index\Colour\Colour;
|
|
use Index\Colour\ColourRGB;
|
|
use Index\Data\IDbResult;
|
|
use Hanyuu\Users\IUserInfo;
|
|
|
|
class DbUserInfo implements IUserInfo {
|
|
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;
|
|
}
|
|
}
|