<?php

declare(strict_types=1);

namespace App\Framework\Console\ValueObjects;

/**
 * Represents a single menu option with type safety
 */
final readonly class MenuOption
{
    public function __construct(
        public string $key,
        public string $label,
        public ?string $description = null,
        public bool $enabled = true
    ) {
    }

    public static function create(string $key, string $label, ?string $description = null): self
    {
        return new self($key, $label, $description);
    }

    public static function separator(): self
    {
        return new self('---', '---', null, false);
    }

    public static function disabled(string $key, string $label, ?string $description = null): self
    {
        return new self($key, $label, $description, false);
    }

    public function isSeparator(): bool
    {
        return $this->key === '---';
    }

    public function isEnabled(): bool
    {
        return $this->enabled;
    }

    public function withDescription(string $description): self
    {
        return new self($this->key, $this->label, $description, $this->enabled);
    }

    public function disable(): self
    {
        return new self($this->key, $this->label, $this->description, false);
    }

    public function enable(): self
    {
        return new self($this->key, $this->label, $this->description, true);
    }
}
