<?php

declare(strict_types=1);

namespace ShieldX\WPCLI;

defined('ABSPATH') || exit;

final class ManualRestoreConfirmation
{
    public const DANGER_PHRASE = 'RESTORE LIVE SITE';

    /**
     * @param array<string,mixed> $assocArgs
     */
    public static function error(array $assocArgs, string $providedPhrase): string
    {
        if (array_key_exists('yes', $assocArgs)) {
            return 'Manual full restore cannot use --yes. Run it from an interactive terminal and type the required confirmation phrase.';
        }

        if (!hash_equals(self::DANGER_PHRASE, trim($providedPhrase))) {
            return 'Manual full restore was cancelled because the required confirmation phrase did not match.';
        }

        return '';
    }
}
