42 lines
935 B
PHP
42 lines
935 B
PHP
<?php
|
|
namespace Mince;
|
|
|
|
use Index\Colour\{Colour,ColourRGB};
|
|
use Index\Data\IDbResult;
|
|
|
|
class UserInfo {
|
|
public function __construct(
|
|
private string $id,
|
|
private string $name,
|
|
private ?int $colour,
|
|
) {}
|
|
|
|
public static function fromResult(IDbResult $result): self {
|
|
return new UserInfo(
|
|
id: $result->getString(0),
|
|
name: $result->getString(1),
|
|
colour: $result->getIntegerOrNull(2),
|
|
);
|
|
}
|
|
|
|
public function getId(): string {
|
|
return $this->id;
|
|
}
|
|
|
|
public function getName(): string {
|
|
return $this->name;
|
|
}
|
|
|
|
public function hasColour(): bool {
|
|
return $this->colour !== null;
|
|
}
|
|
|
|
public function getColourRaw(): ?int {
|
|
return $this->colour;
|
|
}
|
|
|
|
public function getColour(): Colour {
|
|
return $this->colour === null ? Colour::none() : ColourRGB::fromRawRGB($this->colour);
|
|
}
|
|
}
|