<?php
namespace Misuzu\News;
use Carbon\CarbonImmutable;
use Index\Db\DbResult;
class NewsCategoryInfo {
public function __construct(
public private(set) string $id,
public private(set) string $name,
public private(set) string $description,
public private(set) bool $hidden,
public private(set) int $createdTime,
public private(set) int $postsCount,
) {}
public static function fromResult(DbResult $result): NewsCategoryInfo {
return new NewsCategoryInfo(
id: $result->getString(0),
name: $result->getString(1),
description: $result->getString(2),
hidden: $result->getBoolean(3),
createdTime: $result->getInteger(4),
postsCount: $result->getInteger(5),
);
}
public CarbonImmutable $createdAt {
get => CarbonImmutable::createFromTimestampUTC($this->createdTime);