<?php

declare(strict_types=1);

namespace App\Framework\LiveComponents\ValueObjects;

/**
 * Represents the result of parameter matching with flexible naming conventions
 */
final readonly class ParameterMatch
{
    private function __construct(
        public bool $found,
        public mixed $value
    ) {
    }

    public static function found(mixed $value): self
    {
        return new self(true, $value);
    }

    public static function notFound(): self
    {
        return new self(false, null);
    }

    public function isFound(): bool
    {
        return $this->found;
    }

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

    public function getValueOr(mixed $default): mixed
    {
        return $this->found ? $this->value : $default;
    }
}
