misuzu/src/News/NewsCategoryInfo.php

56 lines
1.3 KiB
PHP
Raw Normal View History

2023-07-15 17:02:46 +00:00
<?php
namespace Misuzu\News;
use Index\DateTime;
use Index\Data\IDbResult;
class NewsCategoryInfo {
2024-02-07 00:04:45 +00:00
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),
);
2023-07-15 17:02:46 +00:00
}
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;
}
}