<?php

namespace App\Domain\Manga\Domain\Model\ValueObject;

use App\Domain\Manga\Domain\Exception\InvalidMangaSlugException;

readonly class MangaSlug
{
    public function __construct(
        private string $value
    ) {
        if (empty(trim($value))) {
            throw new InvalidMangaSlugException('Manga slug cannot be empty');
        }

        if (!preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/', $value)) {
            throw new InvalidMangaSlugException('Invalid manga slug format');
        }
    }

    public function getValue(): string
    {
        return $this->value;
    }
}
