2023-07-15 02:05:49 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu\Changelog;
|
|
|
|
|
|
|
|
use Index\DateTime;
|
|
|
|
use Index\Data\IDbResult;
|
|
|
|
|
|
|
|
class ChangeInfo {
|
|
|
|
private string $id;
|
|
|
|
private ?string $userId;
|
|
|
|
private int $action;
|
|
|
|
private int $created;
|
|
|
|
private string $summary;
|
|
|
|
private string $body;
|
|
|
|
|
2023-08-05 13:50:15 +00:00
|
|
|
public function __construct(IDbResult $result) {
|
2023-07-15 02:05:49 +00:00
|
|
|
$this->id = (string)$result->getInteger(0);
|
|
|
|
$this->userId = $result->isNull(1) ? null : (string)$result->getInteger(1);
|
|
|
|
$this->action = $result->getInteger(2);
|
|
|
|
$this->created = $result->getInteger(3);
|
|
|
|
$this->summary = $result->getString(4);
|
|
|
|
$this->body = $result->getString(5);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getId(): string {
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
2023-09-06 13:50:19 +00:00
|
|
|
public function hasUserId(): bool {
|
|
|
|
return $this->userId !== null;
|
|
|
|
}
|
|
|
|
|
2023-07-15 02:05:49 +00:00
|
|
|
public function getUserId(): ?string {
|
|
|
|
return $this->userId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getActionId(): int {
|
|
|
|
return $this->action;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAction(): string {
|
|
|
|
return Changelog::convertFromActionId($this->action);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getActionText(): string {
|
|
|
|
return Changelog::actionText($this->action);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCreatedTime(): int {
|
|
|
|
return $this->created;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCreatedAt(): DateTime {
|
|
|
|
return DateTime::fromUnixTimeSeconds($this->created);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDate(): string {
|
|
|
|
return gmdate('Y-m-d', $this->created);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSummary(): string {
|
|
|
|
return $this->summary;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasBody(): bool {
|
|
|
|
return !empty($this->body);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBody(): string {
|
|
|
|
return $this->body;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCommentsCategoryName(): string {
|
|
|
|
return sprintf('changelog-date-%s', $this->getDate());
|
|
|
|
}
|
|
|
|
}
|