misuzu/src/Users/WarningInfo.php

62 lines
1.4 KiB
PHP

<?php
namespace Misuzu\Users;
use Index\DateTime;
use Index\Data\IDbResult;
class WarningInfo {
public function __construct(
private string $id,
private string $userId,
private ?string $modId,
private string $body,
private int $created,
) {}
public static function fromResult(IDbResult $result): WarningInfo {
return new WarningInfo(
id: $result->getString(0),
userId: $result->getString(1),
modId: $result->getStringOrNull(2),
body: $result->getString(3),
created: $result->getInteger(4)
);
}
public function getId(): string {
return $this->id;
}
public function getUserId(): string {
return $this->userId;
}
public function hasModId(): bool {
return $this->modId !== null;
}
public function getModId(): ?string {
return $this->modId;
}
public function hasBody(): bool {
return $this->body !== '';
}
public function getBody(): string {
return $this->body;
}
public function getBodyLines(): array {
return explode("\n", $this->body);
}
public function getCreatedTime(): int {
return $this->created;
}
public function getCreatedAt(): DateTime {
return DateTime::fromUnixTimeSeconds($this->created);
}
}