From 5f11e1997c8c6b775732d7e41275afd87a452b77 Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Tue, 23 Dec 2014 11:36:01 +0000 Subject: [PATCH] Trying to reduce complexity of language init method. --- PHPCI/Helper/Lang.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/PHPCI/Helper/Lang.php b/PHPCI/Helper/Lang.php index fc0f5579..a24c8952 100644 --- a/PHPCI/Helper/Lang.php +++ b/PHPCI/Helper/Lang.php @@ -103,12 +103,7 @@ class Lang */ public static function init(Config $config) { - $matches = array(); - foreach (glob(PHPCI_DIR . 'PHPCI/Languages/lang.*.php') as $file) { - if (preg_match('/lang\.([a-z]{2}\-?[a-z]*)\.php/', $file, $matches)) { - self::$languages[] = $matches[1]; - } - } + self::loadAvailableLanguages(); // Try cookies first: if (isset($_COOKIE) && array_key_exists('phpcilang', $_COOKIE) && self::setLanguage($_COOKIE['phpcilang'])) { @@ -160,4 +155,14 @@ class Lang return $strings; } + + protected static function loadAvailableLanguages() + { + $matches = array(); + foreach (glob(PHPCI_DIR . 'PHPCI/Languages/lang.*.php') as $file) { + if (preg_match('/lang\.([a-z]{2}\-?[a-z]*)\.php/', $file, $matches)) { + self::$languages[] = $matches[1]; + } + } + } }