<?php

declare(strict_types=1);

namespace Plugin\tnt_mcp\src\Mcp\Action;

/**
 * The machine-checkable half of a {@see CoRequirement} (design round 4 §3, D38).
 *
 * A co-requirement's `rule:` is prose written for a human and for an LLM — "same length, both
 * non-empty", "the amount is only read when the flag is on". Prose cannot be evaluated, so
 * `validate_admin_action` could only ever echo it. `check:` adds the one predicate that expresses
 * the same rule mechanically, WITHOUT replacing the prose: the entry keeps saying why, and the
 * validator gains something to run.
 *
 * Four predicates, deliberately. They cover every co-requirement in the shipped catalog, and the
 * vocabulary is small enough that a reviewer can hold all of it — an expression language would be
 * more powerful and unbounded to review (D38 option b, rejected).
 */
enum CoRequirementCheck: string
{
    /** All named fields are arrays of the same, non-zero length — `bis[]` / `preis[]`. */
    case SameLength = 'sameLength';

    /** Every named field is present and non-empty, or none of them may be. */
    case AllPresent = 'allPresent';

    /** At least one of the named fields must be present and non-empty. */
    case AnyPresent = 'anyPresent';

    /**
     * The FIRST field is a flag; the remaining fields are required only when it is truthy —
     * `versandkostenfreiAktiv` / `fVersandkostenfreiAbX`.
     */
    case RequiredWhenTruthy = 'requiredWhenTruthy';

    /** @return list<string> */
    public static function names(): array
    {
        return \array_map(static fn (self $case): string => $case->value, self::cases());
    }
}
