0 follower

Final Class Yiisoft\I18n\LocaleProvider

InheritanceYiisoft\I18n\LocaleProvider

LocaleProvider is a stateful service that stores current locale.

Other services may use it as a dependency.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( Yiisoft\I18n\Locale $defaultLocale )
$defaultLocale Yiisoft\I18n\Locale

                public function __construct(
    private Locale $defaultLocale
) {
}

            
get() public method

public Yiisoft\I18n\Locale get ( )

                public function get(): Locale
{
    return $this->locale ?? $this->defaultLocale;
}

            
isDefaultLocale() public method

public boolean isDefaultLocale ( )

                public function isDefaultLocale(): bool
{
    return $this->locale === null || $this->locale->asString() === $this->defaultLocale->asString();
}

            
set() public method

public void set ( Yiisoft\I18n\Locale $locale )
$locale Yiisoft\I18n\Locale

                public function set(Locale $locale): void
{
    $this->locale = $locale;
}