<?php

declare(strict_types=1);

namespace App\Framework\Console\ValueObjects;

/**
 * Represents a single choice option for interactive selection
 */
final readonly class ChoiceOption
{
    public function __construct(
        public string $value,
        public string $label,
        public bool $selected = false
    ) {
    }

    public static function create(string $value, string $label): self
    {
        return new self($value, $label);
    }

    public static function selected(string $value, string $label): self
    {
        return new self($value, $label, true);
    }

    public function select(): self
    {
        return new self($this->value, $this->label, true);
    }

    public function deselect(): self
    {
        return new self($this->value, $this->label, false);
    }

    public function isSelected(): bool
    {
        return $this->selected;
    }

    public function withLabel(string $label): self
    {
        return new self($this->value, $label, $this->selected);
    }
}
