Skip to content
Snippets Groups Projects
Commit 7528f09e authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Reduce complexity in some of the methods of SimpleSAML\Locale\Language.

parent 8fc2be4f
No related branches found
No related tags found
No related merge requests found
...@@ -117,8 +117,7 @@ class Language ...@@ -117,8 +117,7 @@ class Language
} }
// run custom getLanguage function if defined // run custom getLanguage function if defined
if (isset($this->customFunction)) { if (isset($this->customFunction) && is_callable($this->customFunction)) {
assert('is_callable($customFunction)');
$customLanguage = call_user_func($this->customFunction, $this); $customLanguage = call_user_func($this->customFunction, $this);
if ($customLanguage !== null && $customLanguage !== false) { if ($customLanguage !== null && $customLanguage !== false) {
return $customLanguage; return $customLanguage;
...@@ -216,12 +215,10 @@ class Language ...@@ -216,12 +215,10 @@ class Language
*/ */
public function getLanguageList() public function getLanguageList()
{ {
$thisLang = $this->getLanguage(); $current = $this->getLanguage();
$lang = array(); $list = array_fill_keys($this->availableLanguages, false);
foreach ($this->availableLanguages as $nl) { $list[$current] = true;
$lang[$nl] = ($nl == $thisLang); return $list;
}
return $lang;
} }
...@@ -232,11 +229,7 @@ class Language ...@@ -232,11 +229,7 @@ class Language
*/ */
public function isLanguageRTL() public function isLanguageRTL()
{ {
$thisLang = $this->getLanguage(); return in_array($this->getLanguage(), $this->rtlLanguages);
if (in_array($thisLang, $this->rtlLanguages)) {
return true;
}
return false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment