<?php

namespace Formatrica\Capability;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * A save-path rule that gates one premium capability.
 *
 * The Premium_Save_Guard calls enforce() only when the rule's capability is
 * unavailable. A rule reverts unauthorized NEW/CHANGED config back to the
 * previously-stored value (preserve-existing semantics: a license lapse must
 * never destroy Pro-authored data) and returns structured rejection entries
 * describing what it reverted.
 */
interface Premium_Config_Rule_Interface
{
    /**
     * Canonical capability key this rule guards.
     */
    public function capability(): string;

    /**
     * Enforce the gate against the sanitised config.
     *
     * @param array<string, mixed> $config   Full form config (fields + options), mutated by reference.
     * @param array<string, mixed> $existing  Previously-stored config (raw), for preserve-existing.
     * @return list<array<string, string>>    Rejection entries: key, reason, capability, feature.
     */
    public function enforce(array &$config, array $existing): array;
}
