mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2026-01-23 02:35:23 +00:00
simplify logic and improve readability
function was only used in one place and only indirectly tested, so it could be inlined, which also makes the test for null and the extra variable allocation unnecessary
This commit is contained in:
parent
f2164353c3
commit
be6a3702fc
1 changed files with 5 additions and 18 deletions
|
|
@ -65,7 +65,7 @@ class TemplateSwitcher
|
|||
}
|
||||
|
||||
/**
|
||||
* get currently loaded template
|
||||
* get user selected template or fallback
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
|
|
@ -73,8 +73,10 @@ class TemplateSwitcher
|
|||
*/
|
||||
public static function getTemplate(): string
|
||||
{
|
||||
$selectedTemplate = self::getSelectedByUserTemplate();
|
||||
return $selectedTemplate ?? self::$_templateFallback;
|
||||
if (array_key_exists('template', $_COOKIE) && self::isTemplateAvailable($_COOKIE['template'])) {
|
||||
return $_COOKIE['template'];
|
||||
}
|
||||
return self::$_templateFallback;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -104,19 +106,4 @@ class TemplateSwitcher
|
|||
error_log('template "' . $template . '" is not in the list of `availabletemplates` in the configuration file');
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the template selected by user
|
||||
*
|
||||
* @access private
|
||||
* @static
|
||||
* @return string|null
|
||||
*/
|
||||
private static function getSelectedByUserTemplate(): ?string
|
||||
{
|
||||
if (array_key_exists('template', $_COOKIE) && self::isTemplateAvailable($_COOKIE['template'])) {
|
||||
return $_COOKIE['template'];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue