misuzu/src/News/NewsCategoryInfo.php

56 lines
1.3 KiB
PHP

<?php
namespace Misuzu\News;
use Index\DateTime;
use Index\Data\IDbResult;
class NewsCategoryInfo {
public function __construct(
private string $id,
private string $name,
private string $description,
private bool $hidden,
private int $created,
private int $posts,
) {}
public static function fromResult(IDbResult $result): NewsCategoryInfo {
return new NewsCategoryInfo(
id: $result->getString(0),
name: $result->getString(1),
description: $result->getString(2),
hidden: $result->getBoolean(3),
created: $result->getInteger(4),
posts: $result->getInteger(5),
);
}
public function getId(): string {
return $this->id;
}
public function getName(): string {
return $this->name;
}
public function getDescription(): string {
return $this->description;
}
public function isHidden(): bool {
return $this->hidden;
}
public function getCreatedTime(): int {
return $this->created;
}
public function getCreatedAt(): DateTime {
return DateTime::fromUnixTimeSeconds($this->created);
}
public function getPostsCount(): int {
return $this->posts;
}
}