From 52be6145a093fd9eb3872d87847f8d0fe41aa8fb Mon Sep 17 00:00:00 2001 From: Bas Kamer Date: Tue, 12 Nov 2013 15:37:56 +0100 Subject: [PATCH] review feedback --- src/SlmLocale/View/Helper/LocaleMenu.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/SlmLocale/View/Helper/LocaleMenu.php b/src/SlmLocale/View/Helper/LocaleMenu.php index 1862701..b3e7938 100644 --- a/src/SlmLocale/View/Helper/LocaleMenu.php +++ b/src/SlmLocale/View/Helper/LocaleMenu.php @@ -244,8 +244,8 @@ public function __toString() $labelLocale = $this->getLabelInCurrentLocale() ? $locale : $current; $url = $this->getView()->localeUrl($locale); - $title = $this->callLocale($this->getTitleMethod(), $locale, $titleLocale); - $label = $this->callLocale($this->getLabelMethod(), $locale, $labelLocale); + $title = $this->getLocaleProperty($this->getTitleMethod(), $locale, $titleLocale); + $label = $this->getLocaleProperty($this->getLabelMethod(), $locale, $labelLocale); $item = sprintf( '
  • %s
  • ' . "\n", @@ -297,16 +297,24 @@ protected function checkLocaleMethod($method) } } - protected function callLocale($method, $locale, $in_locale = false) + /** + * Retrieves a value by property from Locale + * + * @param $property + * @param $locale + * @param bool $in_locale + * @return mixed + */ + protected function getLocaleProperty($property, $locale, $in_locale = false) { - $function = sprintf('\Locale::get%s', ucfirst($method)); + $callback = sprintf('\Locale::get%s', ucfirst($property)); $args = array($locale); - if ($in_locale && !in_array($method, array('primaryLanguage', 'region', 'script'))) { + if ($in_locale && !in_array($property, array('primaryLanguage', 'region', 'script'))) { $args[] = $in_locale; } - return call_user_func_array($function, $args); + return call_user_func_array($callback, $args); } } \ No newline at end of file