@@ -138,13 +138,13 @@ discard block |
||
| 138 | 138 | // Get the namespace name |
| 139 | 139 | $namespace = $this->__default_namespace__; |
| 140 | 140 | $separatorPosition = strrpos($template, '::'); |
| 141 | - if($separatorPosition !== false) |
|
| 141 | + if ($separatorPosition !== false) |
|
| 142 | 142 | { |
| 143 | 143 | $namespace = substr($template, 0, $separatorPosition); |
| 144 | 144 | $template = substr($template, $separatorPosition + 2); |
| 145 | 145 | } |
| 146 | 146 | // Check if the namespace is defined |
| 147 | - if(!isset($this->__namespaces__[$namespace])) |
|
| 147 | + if (!isset($this->__namespaces__[$namespace])) |
|
| 148 | 148 | { |
| 149 | 149 | return $template; |
| 150 | 150 | } |
@@ -165,13 +165,13 @@ discard block |
||
| 165 | 165 | { |
| 166 | 166 | // Get the template path |
| 167 | 167 | $templatePath = $this->__path(); |
| 168 | - if(!@is_readable($templatePath)) |
|
| 168 | + if (!@is_readable($templatePath)) |
|
| 169 | 169 | { |
| 170 | 170 | return ''; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // Save the template properties. |
| 174 | - foreach($vars as $name => $value) |
|
| 174 | + foreach ($vars as $name => $value) |
|
| 175 | 175 | { |
| 176 | 176 | $this->__set((string)$name, $value); |
| 177 | 177 | } |
@@ -182,8 +182,7 @@ discard block |
||
| 182 | 182 | include $templatePath; |
| 183 | 183 | $content = ob_get_clean(); |
| 184 | 184 | |
| 185 | - return $this->__extends__ === null ? $content : |
|
| 186 | - // Render the extended template with the same properties. |
|
| 185 | + return $this->__extends__ === null ? $content : // Render the extended template with the same properties. |
|
| 187 | 186 | $this->__extends__->__render($this->__properties__); |
| 188 | 187 | }; |
| 189 | 188 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function setLocale(string $sLocale): void |
| 58 | 58 | { |
| 59 | - if(($sLocale = trim($sLocale))) |
|
| 59 | + if (($sLocale = trim($sLocale))) |
|
| 60 | 60 | { |
| 61 | 61 | $this->sDefaultLocale = $sLocale; |
| 62 | 62 | } |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | private function _loadTranslations(string $sLanguage, string $sPrefix, array $aTranslations): void |
| 75 | 75 | { |
| 76 | - foreach($aTranslations as $sKey => $xTranslation) |
|
| 76 | + foreach ($aTranslations as $sKey => $xTranslation) |
|
| 77 | 77 | { |
| 78 | 78 | $sKey = trim($sKey); |
| 79 | 79 | $sKey = ($sPrefix) ? $sPrefix . '.' . $sKey : $sKey; |
| 80 | - if(is_array($xTranslation)) |
|
| 80 | + if (is_array($xTranslation)) |
|
| 81 | 81 | { |
| 82 | 82 | // Recursively read the translations in the array |
| 83 | 83 | $this->_loadTranslations($sLanguage, $sKey, $xTranslation); |
@@ -100,18 +100,18 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function loadTranslations(string $sFilePath, string $sLanguage): bool |
| 102 | 102 | { |
| 103 | - if(!file_exists($sFilePath)) |
|
| 103 | + if (!file_exists($sFilePath)) |
|
| 104 | 104 | { |
| 105 | 105 | return false; |
| 106 | 106 | } |
| 107 | 107 | $aTranslations = require($sFilePath); |
| 108 | - if(!is_array($aTranslations)) |
|
| 108 | + if (!is_array($aTranslations)) |
|
| 109 | 109 | { |
| 110 | 110 | return false; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // Load the translations |
| 114 | - if(!isset($this->aTranslations[$sLanguage])) |
|
| 114 | + if (!isset($this->aTranslations[$sLanguage])) |
|
| 115 | 115 | { |
| 116 | 116 | $this->aTranslations[$sLanguage] = []; |
| 117 | 117 | } |
@@ -133,16 +133,16 @@ discard block |
||
| 133 | 133 | public function trans(string $sText, array $aPlaceHolders = [], string $sLanguage = ''): string |
| 134 | 134 | { |
| 135 | 135 | $sText = trim($sText); |
| 136 | - if(empty($sLanguage)) |
|
| 136 | + if (empty($sLanguage)) |
|
| 137 | 137 | { |
| 138 | 138 | $sLanguage = $this->sDefaultLocale; |
| 139 | 139 | } |
| 140 | - if(!isset($this->aTranslations[$sLanguage][$sText])) |
|
| 140 | + if (!isset($this->aTranslations[$sLanguage][$sText])) |
|
| 141 | 141 | { |
| 142 | 142 | return $sText; |
| 143 | 143 | } |
| 144 | 144 | $sMessage = $this->aTranslations[$sLanguage][$sText]; |
| 145 | - if(!empty($aPlaceHolders)) |
|
| 145 | + if (!empty($aPlaceHolders)) |
|
| 146 | 146 | { |
| 147 | 147 | $aVars = array_map(function($sVar) { |
| 148 | 148 | return ':' . $sVar; |
@@ -162,16 +162,16 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function translations(string $sKey, string $sLanguage = ''): array |
| 164 | 164 | { |
| 165 | - if(empty($sLanguage)) |
|
| 165 | + if (empty($sLanguage)) |
|
| 166 | 166 | { |
| 167 | 167 | $sLanguage = $this->sDefaultLocale; |
| 168 | 168 | } |
| 169 | 169 | $aKeys = explode('.', $sKey); |
| 170 | 170 | |
| 171 | 171 | $aTranslations = $this->aRawTranslations[$sLanguage]; |
| 172 | - foreach($aKeys as $sKey) |
|
| 172 | + foreach ($aKeys as $sKey) |
|
| 173 | 173 | { |
| 174 | - if($sKey !== '') |
|
| 174 | + if ($sKey !== '') |
|
| 175 | 175 | { |
| 176 | 176 | $aTranslations = $aTranslations[$sKey] ?? []; |
| 177 | 177 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | return file_get_contents($sPath); |
| 39 | 39 | } |
| 40 | - catch(Exception $e) |
|
| 40 | + catch (Exception $e) |
|
| 41 | 41 | { |
| 42 | 42 | return false; |
| 43 | 43 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | return Minifier::minify($sCode); |
| 58 | 58 | } |
| 59 | - catch(Exception $e) |
|
| 59 | + catch (Exception $e) |
|
| 60 | 60 | { |
| 61 | 61 | return false; |
| 62 | 62 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function minify(string $sJsFile, string $sMinFile): bool |
| 74 | 74 | { |
| 75 | - if(($sJsCode = $this->readFile($sJsFile)) === false || |
|
| 75 | + if (($sJsCode = $this->readFile($sJsFile)) === false || |
|
| 76 | 76 | ($sMinCode = $this->minifyCode($sJsCode)) === false) |
| 77 | 77 | { |
| 78 | 78 | return false; |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | |
| 36 | 36 | protected function setUp(): void |
| 37 | 37 | { |
| 38 | - $this->sConfigDir = __DIR__ . '/../config'; |
|
| 38 | + $this->sConfigDir = __DIR__ . '/../config'; |
|
| 39 | 39 | $this->xConfigSetter = new ConfigSetter(); |
| 40 | 40 | $this->xConfigReader = new ConfigReader($this->xConfigSetter); |
| 41 | 41 | $this->xConfig = $this->xConfigSetter->newConfig(['core' => ['language' => 'en']]); |
@@ -90,11 +90,11 @@ |
||
| 90 | 90 | $sKey = trim($sKey, ' .'); |
| 91 | 91 | $aKeys = Value::explodeName($sKey); |
| 92 | 92 | $aValues = $this->aValues; |
| 93 | - foreach($aKeys as $_sKey) |
|
| 93 | + foreach ($aKeys as $_sKey) |
|
| 94 | 94 | { |
| 95 | 95 | $aValues = $aValues[$_sKey] ?? []; |
| 96 | 96 | } |
| 97 | - if(!Value::containsOptions($aValues)) |
|
| 97 | + if (!Value::containsOptions($aValues)) |
|
| 98 | 98 | { |
| 99 | 99 | return []; |
| 100 | 100 | } |
@@ -34,13 +34,13 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | public static function containsOptions($xValue): bool |
| 36 | 36 | { |
| 37 | - if(!is_array($xValue) || count($xValue) === 0) |
|
| 37 | + if (!is_array($xValue) || count($xValue) === 0) |
|
| 38 | 38 | { |
| 39 | 39 | return false; |
| 40 | 40 | } |
| 41 | - foreach(array_keys($xValue) as $xKey) |
|
| 41 | + foreach (array_keys($xValue) as $xKey) |
|
| 42 | 42 | { |
| 43 | - if(!is_string($xKey)) |
|
| 43 | + if (!is_string($xKey)) |
|
| 44 | 44 | { |
| 45 | 45 | return false; |
| 46 | 46 | } |
@@ -35,13 +35,13 @@ |
||
| 35 | 35 | public static function read(string $sConfigFile): array |
| 36 | 36 | { |
| 37 | 37 | $sConfigFile = realpath($sConfigFile); |
| 38 | - if(!is_readable($sConfigFile)) |
|
| 38 | + if (!is_readable($sConfigFile)) |
|
| 39 | 39 | { |
| 40 | 40 | throw new FileAccess($sConfigFile); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $aConfigOptions = include($sConfigFile); |
| 44 | - if(!is_array($aConfigOptions)) |
|
| 44 | + if (!is_array($aConfigOptions)) |
|
| 45 | 45 | { |
| 46 | 46 | throw new FileContent($sConfigFile); |
| 47 | 47 | } |
@@ -38,19 +38,19 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | public static function read(string $sConfigFile): array |
| 40 | 40 | { |
| 41 | - if(!extension_loaded('yaml')) |
|
| 41 | + if (!extension_loaded('yaml')) |
|
| 42 | 42 | { |
| 43 | 43 | throw new YamlExtension(); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $sConfigFile = realpath($sConfigFile); |
| 47 | - if(!is_readable($sConfigFile)) |
|
| 47 | + if (!is_readable($sConfigFile)) |
|
| 48 | 48 | { |
| 49 | 49 | throw new FileAccess($sConfigFile); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $aConfigOptions = yaml_parse_file($sConfigFile); |
| 53 | - if(!is_array($aConfigOptions)) |
|
| 53 | + if (!is_array($aConfigOptions)) |
|
| 54 | 54 | { |
| 55 | 55 | throw new FileContent($sConfigFile); |
| 56 | 56 | } |
@@ -37,14 +37,14 @@ |
||
| 37 | 37 | public static function read(string $sConfigFile): array |
| 38 | 38 | { |
| 39 | 39 | $sConfigFile = realpath($sConfigFile); |
| 40 | - if(!is_readable($sConfigFile)) |
|
| 40 | + if (!is_readable($sConfigFile)) |
|
| 41 | 41 | { |
| 42 | 42 | throw new FileAccess($sConfigFile); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | $sFileContent = file_get_contents($sConfigFile); |
| 46 | 46 | $aConfigOptions = json_decode($sFileContent, true); |
| 47 | - if(!is_array($aConfigOptions)) |
|
| 47 | + if (!is_array($aConfigOptions)) |
|
| 48 | 48 | { |
| 49 | 49 | throw new FileContent($sConfigFile); |
| 50 | 50 | } |