<?php
namespace Misuzu\Changelog;

use Stringable;
use Index\DateTime;
use Index\Data\IDbResult;

class ChangeTagInfo implements Stringable {
    private string $id;
    private string $name;
    private string $description;
    private int $created;
    private int $archived;
    private int $changes;

    public function __construct(IDbResult $result) {
        $this->id = (string)$result->getInteger(0);
        $this->name = $result->getString(1);
        $this->description = $result->getString(2);
        $this->created = $result->getInteger(3);
        $this->archived = $result->getInteger(4);
        $this->changes = $result->getInteger(5);
    }

    public function getId(): string {
        return $this->id;
    }

    public function getName(): string {
        return $this->name;
    }

    public function getDescription(): string {
        return $this->description;
    }

    public function getCreatedTime(): int {
        return $this->created;
    }

    public function getCreatedAt(): DateTime {
        return DateTime::fromUnixTimeSeconds($this->created);
    }

    public function getArchivedTime(): int {
        return $this->archived;
    }

    public function getArchivedAt(): DateTime {
        return DateTime::fromUnixTimeSeconds($this->created);
    }

    public function isArchived(): bool {
        return $this->archived > 0;
    }

    public function getChangesCount(): int {
        return $this->changes;
    }

    public function __toString(): string {
        return $this->id;
    }
}
