This repository has been archived on 2025-01-28. You can view files and clone it, but cannot push or open issues or pull requests.
misuzu-interim/src/News/NewsCategoryInfo.php

31 lines
938 B
PHP

<?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);
}
}