misuzu/src/Users/WarningInfo.php

58 lines
1.3 KiB
PHP
Raw Normal View History

2023-07-26 22:43:50 +00:00
<?php
namespace Misuzu\Users;
use Index\DateTime;
use Index\Data\IDbResult;
class WarningInfo {
private string $id;
private string $userId;
private ?string $modId;
private string $body;
private int $created;
public function __construct(IDbResult $result) {
$this->id = (string)$result->getInteger(0);
$this->userId = (string)$result->getInteger(1);
$this->modId = $result->isNull(2) ? null : (string)$result->getInteger(2);
$this->body = $result->getString(3);
$this->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);
}
}