<?php

declare(strict_types=1);

namespace App\Framework\Filesystem\ValueObjects;

use App\Framework\Filesystem\FileChangeType;
use DateTimeImmutable;

/**
 * Represents a file system change event
 */
final readonly class FileChangeEvent
{
    public function __construct(
        private string $path,
        private FileChangeType $type,
        private DateTimeImmutable $timestamp
    ) {
    }

    public static function create(string $path, FileChangeType $type): self
    {
        return new self($path, $type, new DateTimeImmutable());
    }

    public function getPath(): string
    {
        return $this->path;
    }

    public function getType(): FileChangeType
    {
        return $this->type;
    }

    public function getTimestamp(): DateTimeImmutable
    {
        return $this->timestamp;
    }

    public function isType(FileChangeType $type): bool
    {
        return $this->type === $type;
    }

    public function isModification(): bool
    {
        return $this->type === FileChangeType::MODIFIED;
    }

    public function isCreation(): bool
    {
        return $this->type === FileChangeType::CREATED;
    }

    public function isDeletion(): bool
    {
        return $this->type === FileChangeType::DELETED;
    }
}
