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

32 lines
938 B
PHP
Raw Normal View History

2023-07-15 17:02:46 +00:00
<?php
namespace Misuzu\News;
use Carbon\CarbonImmutable;
2024-10-05 02:40:29 +00:00
use Index\Db\DbResult;
2023-07-15 17:02:46 +00:00
class NewsCategoryInfo {
2024-02-07 00:04:45 +00:00
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,
2024-02-07 00:04:45 +00:00
) {}
2024-10-05 02:40:29 +00:00
public static function fromResult(DbResult $result): NewsCategoryInfo {
2024-02-07 00:04:45 +00:00
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),
2024-02-07 00:04:45 +00:00
);
2023-07-15 17:02:46 +00:00
}
public CarbonImmutable $createdAt {
get => CarbonImmutable::createFromTimestampUTC($this->createdTime);
2023-07-15 17:02:46 +00:00
}
}