<?php

declare(strict_types=1);

namespace App\Framework\EventSourcing\Demo;

final readonly class DemoAggregateDomainId
{
    public function __construct(
        private string $id
    ) {
    }

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

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

    public static function generate(): self
    {
        return new self(uniqid('demo_', true));
    }

    public static function fromString(string $id): self
    {
        return new self($id);
    }

    public function equals(self $other): bool
    {
        return $this->id === $other->id;
    }
}
