<?php
declare(strict_types=1);

namespace Ekesto\CacheInvalidator\Core\Multilingual;

use Ekesto\CacheInvalidator\Core\Contracts\MultilingualProviderInterface;

/**
 * Lite-safe holder for the active multilingual provider.
 *
 * Defaults to {@see NullMultilingualProvider}. 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 MultilingualProviderRegistry
{
    /** @var MultilingualProviderInterface|null */
    private static ?MultilingualProviderInterface $provider = null;

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

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

        return self::$provider;
    }
}
