2023-08-28 01:17:34 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu\Forum;
|
|
|
|
|
|
|
|
use Index\DateTime;
|
|
|
|
use Index\Data\IDbResult;
|
|
|
|
|
|
|
|
class ForumTopicRedirectInfo {
|
2024-02-07 00:04:45 +00:00
|
|
|
public function __construct(
|
|
|
|
private string $topicId,
|
|
|
|
private ?string $userId,
|
|
|
|
private string $link,
|
|
|
|
private int $created,
|
|
|
|
) {}
|
|
|
|
|
|
|
|
public static function fromResult(IDbResult $result): ForumTopicRedirectInfo {
|
|
|
|
return new ForumTopicRedirectInfo(
|
|
|
|
topicId: $result->getString(0),
|
|
|
|
userId: $result->getStringOrNull(1),
|
|
|
|
link: $result->getString(2),
|
|
|
|
created: $result->getInteger(3),
|
|
|
|
);
|
2023-08-28 01:17:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getTopicId(): string {
|
|
|
|
return $this->topicId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasUserId(): bool {
|
|
|
|
return $this->userId !== null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUserId(): ?string {
|
|
|
|
return $this->userId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLinkTarget(): string {
|
|
|
|
return $this->link;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCreatedTime(): int {
|
|
|
|
return $this->created;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCreatedAt(): DateTime {
|
|
|
|
return DateTime::fromUnixTimeSeconds($this->created);
|
|
|
|
}
|
|
|
|
}
|