<?php

declare(strict_types=1);

namespace ROITheme\Admin\Domain\ValueObjects;

/**
 * Value Object para representar un item del menú
 *
 * Domain - Objeto inmutable sin WordPress
 */
final class MenuItem
{
    /**
     * @param string $pageTitle Título de la página
     * @param string $menuTitle Título del menú
     * @param string $capability Capacidad requerida
     * @param string $menuSlug Slug del menú
     * @param string $icon Ícono del menú
     * @param int $position Posición en el menú
     */
    public function __construct(
        private readonly string $pageTitle,
        private readonly string $menuTitle,
        private readonly string $capability,
        private readonly string $menuSlug,
        private readonly string $icon,
        private readonly int $position
    ) {
        $this->validate();
    }

    private function validate(): void
    {
        if (empty($this->pageTitle)) {
            throw new \InvalidArgumentException('Page title cannot be empty');
        }

        if (empty($this->menuTitle)) {
            throw new \InvalidArgumentException('Menu title cannot be empty');
        }

        if (empty($this->capability)) {
            throw new \InvalidArgumentException('Capability cannot be empty');
        }

        if (empty($this->menuSlug)) {
            throw new \InvalidArgumentException('Menu slug cannot be empty');
        }

        if ($this->position < 0) {
            throw new \InvalidArgumentException('Position must be >= 0');
        }
    }

    public function getPageTitle(): string
    {
        return $this->pageTitle;
    }

    public function getMenuTitle(): string
    {
        return $this->menuTitle;
    }

    public function getCapability(): string
    {
        return $this->capability;
    }

    public function getMenuSlug(): string
    {
        return $this->menuSlug;
    }

    public function getIcon(): string
    {
        return $this->icon;
    }

    public function getPosition(): int
    {
        return $this->position;
    }
}
