2023-07-28 23:17:37 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu\Counters;
|
|
|
|
|
2024-08-04 21:37:12 +00:00
|
|
|
use Carbon\CarbonImmutable;
|
2023-07-28 23:17:37 +00:00
|
|
|
use Index\Data\IDbResult;
|
|
|
|
|
|
|
|
class CounterInfo {
|
2024-02-07 00:04:45 +00:00
|
|
|
public function __construct(
|
|
|
|
private string $name,
|
|
|
|
private int $value,
|
|
|
|
private int $updated,
|
|
|
|
) {}
|
2023-07-28 23:17:37 +00:00
|
|
|
|
2024-02-07 00:04:45 +00:00
|
|
|
public static function fromResult(IDbResult $result): CounterInfo {
|
|
|
|
return new CounterInfo(
|
|
|
|
name: $result->getString(0),
|
|
|
|
value: $result->getInteger(1),
|
|
|
|
updated: $result->getInteger(2),
|
|
|
|
);
|
2023-07-28 23:17:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(): string {
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getValue(): int {
|
|
|
|
return $this->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUpdatedTime(): int {
|
|
|
|
return $this->updated;
|
|
|
|
}
|
|
|
|
|
2024-08-04 21:37:12 +00:00
|
|
|
public function getUpdatedAt(): CarbonImmutable {
|
|
|
|
return CarbonImmutable::createFromTimestampUTC($this->updated);
|
2023-07-28 23:17:37 +00:00
|
|
|
}
|
|
|
|
}
|