<?php

// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound -- APD is the established namespace shared with the Pro add-on and retained for backward compatibility.
namespace APD\Support;

defined('ABSPATH') || exit;

class Nonces
{
    public static function runtime() : string
    {
        return wp_create_nonce('wp_rest');
    }

    public static function cartSubmission() : string
    {
        return wp_create_nonce('apd_add_to_cart');
    }

    public static function verifyCartSubmission(string $nonce) : bool
    {
        $nonce = sanitize_text_field($nonce);
        return $nonce !== '' && (bool) wp_verify_nonce($nonce, 'apd_add_to_cart');
    }
}
