Kdyby\Translation\Translator::assertValidLocale PHP Method

assertValidLocale() protected method

Asserts that the locale is valid, throws an Exception if not.
protected assertValidLocale ( string $locale )
$locale string Locale to tests
    protected function assertValidLocale($locale)
    {
        if (preg_match('~^[a-z0-9@_\\.\\-]*\\z~i', $locale) !== 1) {
            throw new \InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale));
        }
    }

Usage Example

Beispiel #1
0
 protected function assertValidLocale($locale)
 {
     try {
         parent::assertValidLocale($locale);
     } catch (InvalidArgumentException $ex) {
     }
 }