<?php
declare(strict_types=1);

namespace Ekesto\CacheAutopilot\Access;

/**
 * Lite-safe holder for the active access-control override provider.
 *
 * Defaults to {@see NullAccessOverrideProvider} (admins only). The premium build
 * swaps in a real provider via {@see self::setProvider()} from a strippable Pro
 * registrar. This holder never references the premium namespace.
 */
final class AccessOverrideProviderRegistry
{
    /** @var AccessOverrideProviderInterface|null */
    private static ?AccessOverrideProviderInterface $provider = null;

    /**
     * Register the active override provider.
     *
     * @param AccessOverrideProviderInterface $provider
     * @return void
     */
    public static function setProvider(AccessOverrideProviderInterface $provider): void
    {
        self::$provider = $provider;
    }

    /**
     * Return the active provider, falling back to the Lite-safe no-op default.
     *
     * @return AccessOverrideProviderInterface
     */
    public static function current(): AccessOverrideProviderInterface
    {
        if (self::$provider === null) {
            self::$provider = new NullAccessOverrideProvider();
        }

        return self::$provider;
    }
}
