<?php

declare(strict_types=1);

namespace App\Administration\Domain\Exception;

use App\Administration\Domain\Model\HomeworkRules\RuleType;
use DomainException;

use function implode;
use function sprintf;

final class HomeworkRuleParamsInvalidException extends DomainException
{
    /**
     * @param string[] $missing
     */
    public static function missingParams(RuleType $type, array $missing): self
    {
        return new self(sprintf(
            'La règle "%s" requiert les paramètres manquants : %s.',
            $type->value,
            implode(', ', $missing),
        ));
    }

    public static function invalidValue(RuleType $type, string $param, string $reason): self
    {
        return new self(sprintf(
            'La règle "%s", paramètre "%s" : %s.',
            $type->value,
            $param,
            $reason,
        ));
    }
}
