codemix\localeurls\UrlManager::matchCode PHP Method

matchCode() protected method

If the code is a single language code, and matches either - an exact language as configured (ll) - a language with a country wildcard (ll-*) this language code is returned. If the code also contains a country code, and matches either - an exact language/country code as configured (ll-CC) - a language with a country wildcard (ll-*) the code with uppercase country is returned. If only the language part matches a configured language, that language is returned.
protected matchCode ( string $code ) : array
$code string the code to match
return array of [language, country], [language, null] or [null, null] if no match
    protected function matchCode($code)
    {
        $language = $code;
        $country = null;
        $parts = explode('-', $code);
        if (count($parts) === 2) {
            $language = $parts[0];
            $country = strtoupper($parts[1]);
        }
        if (in_array($code, $this->languages)) {
            return [$language, $country];
        } elseif ($country && in_array("{$language}-{$country}", $this->languages) || in_array("{$language}-*", $this->languages)) {
            return [$language, $country];
        } elseif (in_array($language, $this->languages)) {
            return [$language, null];
        } else {
            return [null, null];
        }
    }