<?php

declare(strict_types=1);

namespace Plugin\tnt_mcp\src\Mcp\Mode;

/**
 * Operating mode of the MCP server, set by the merchant in the plugin settings.
 *
 * - {@see Mode::Limited} (DEFAULT, safe): only reversible endpoints run; destructive/irreversible
 *   ones are denied by the central {@see ModeGuard}.
 * - {@see Mode::Full}: every endpoint runs.
 *
 * The default is deliberately the safe one, so a fresh install or an unreadable setting can never
 * accidentally expose a destructive endpoint.
 */
enum Mode: string
{
    case Full    = 'full';
    case Limited = 'limited';

    /**
     * Resolve a raw stored setting value to a Mode, defaulting to the SAFE {@see Mode::Limited}
     * for anything that is not exactly "full" (null, empty, typo, tampered value).
     */
    public static function fromConfig(?string $raw): self
    {
        return $raw === self::Full->value ? self::Full : self::Limited;
    }
}
