@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | */ |
210 | 210 | protected function loadCultureData($key) |
211 | 211 | { |
212 | - foreach(self::$bundleNames as $bundleKey => $bundleName) |
|
212 | + foreach (self::$bundleNames as $bundleKey => $bundleName) |
|
213 | 213 | { |
214 | - if($key == $bundleKey) |
|
214 | + if ($key == $bundleKey) |
|
215 | 215 | { |
216 | - if(!array_key_exists($this->culture, self::$data)) |
|
216 | + if (!array_key_exists($this->culture, self::$data)) |
|
217 | 217 | self::$data[$this->culture] = []; |
218 | 218 | |
219 | 219 | self::$data[$this->culture][$bundleKey] = \ResourceBundle::create($this->culture, $bundleName, true); |
@@ -231,15 +231,15 @@ discard block |
||
231 | 231 | * @param string $key bundle name. |
232 | 232 | * @return mixed the specific ICU data. |
233 | 233 | */ |
234 | - public function findInfo($path='/', $key = null) |
|
234 | + public function findInfo($path = '/', $key = null) |
|
235 | 235 | { |
236 | - if($key === null) |
|
236 | + if ($key === null) |
|
237 | 237 | { |
238 | 238 | // try to guess the bundle from the path. Always defaults to "Core". |
239 | 239 | $key = 'Core'; |
240 | - foreach(self::$bundleNames as $bundleName => $icuBundleName) |
|
240 | + foreach (self::$bundleNames as $bundleName => $icuBundleName) |
|
241 | 241 | { |
242 | - if(strpos($path, $bundleName) === 0) |
|
242 | + if (strpos($path, $bundleName) === 0) |
|
243 | 243 | { |
244 | 244 | $key = $bundleName; |
245 | 245 | break; |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
250 | - if(!array_key_exists($this->culture, self::$data)) |
|
250 | + if (!array_key_exists($this->culture, self::$data)) |
|
251 | 251 | $this->loadCultureData($key); |
252 | - if(!array_key_exists($this->culture, self::$data) || !array_key_exists($key, self::$data[$this->culture])) |
|
252 | + if (!array_key_exists($this->culture, self::$data) || !array_key_exists($key, self::$data[$this->culture])) |
|
253 | 253 | return []; |
254 | 254 | |
255 | 255 | return $this->searchResources(self::$data[$this->culture][$key], $path); |
@@ -263,12 +263,12 @@ discard block |
||
263 | 263 | * @param string $path slash "/" separated array path. |
264 | 264 | * @return mixed the value array using the path |
265 | 265 | */ |
266 | - private function searchResources($resource, $path='/') |
|
266 | + private function searchResources($resource, $path = '/') |
|
267 | 267 | { |
268 | 268 | $index = explode('/', $path); |
269 | - for($i = 0, $k = count($index); $i < $k; ++$i) |
|
269 | + for ($i = 0, $k = count($index); $i < $k; ++$i) |
|
270 | 270 | { |
271 | - if(is_object($resource)) |
|
271 | + if (is_object($resource)) |
|
272 | 272 | $resource = $resource->get($index[$i]); |
273 | 273 | } |
274 | 274 | |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | $reg = substr($this->culture, 3, 2); |
307 | 307 | $language = $this->findInfo("Languages/{$lang}"); |
308 | 308 | $region = $this->findInfo("Countries/{$reg}"); |
309 | - if($region) |
|
310 | - return $language.' ('.$region.')'; |
|
309 | + if ($region) |
|
310 | + return $language . ' (' . $region . ')'; |
|
311 | 311 | else |
312 | 312 | return $language; |
313 | 313 | } |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | } |
331 | 331 | |
332 | 332 | $region = $culture->findInfo("Countries/{$reg}"); |
333 | - if($region) |
|
334 | - return $language.' ('.$region.')'; |
|
333 | + if ($region) |
|
334 | + return $language . ' (' . $region . ')'; |
|
335 | 335 | else |
336 | 336 | return $language; |
337 | 337 | } |
@@ -372,25 +372,25 @@ discard block |
||
372 | 372 | * or CultureInfo::SPECIFIC. |
373 | 373 | * @return array list of culture information available. |
374 | 374 | */ |
375 | - public static function getCultures($type=CultureInfo::ALL) |
|
375 | + public static function getCultures($type = CultureInfo::ALL) |
|
376 | 376 | { |
377 | 377 | $all = \ResourceBundle::getLocales(''); |
378 | 378 | |
379 | - switch($type) |
|
379 | + switch ($type) |
|
380 | 380 | { |
381 | 381 | case CultureInfo::ALL : |
382 | 382 | return $all; |
383 | 383 | case CultureInfo::NEUTRAL : |
384 | - foreach($all as $key => $culture) |
|
384 | + foreach ($all as $key => $culture) |
|
385 | 385 | { |
386 | - if(strlen($culture) != 2) |
|
386 | + if (strlen($culture) != 2) |
|
387 | 387 | unset($all[$key]); |
388 | 388 | } |
389 | 389 | return $all; |
390 | 390 | case CultureInfo::SPECIFIC : |
391 | - foreach($all as $key => $culture) |
|
391 | + foreach ($all as $key => $culture) |
|
392 | 392 | { |
393 | - if(strlen($culture) == 2) |
|
393 | + if (strlen($culture) == 2) |
|
394 | 394 | unset($all[$key]); |
395 | 395 | } |
396 | 396 | return $all; |
@@ -406,19 +406,19 @@ discard block |
||
406 | 406 | */ |
407 | 407 | protected function simplify($obj) |
408 | 408 | { |
409 | - if(is_scalar($obj)) { |
|
409 | + if (is_scalar($obj)) { |
|
410 | 410 | return $obj; |
411 | - } elseif($obj instanceof \ResourceBundle) { |
|
411 | + } elseif ($obj instanceof \ResourceBundle) { |
|
412 | 412 | $array = []; |
413 | - foreach($obj as $k => $v) |
|
413 | + foreach ($obj as $k => $v) |
|
414 | 414 | $array[$k] = $v; |
415 | 415 | } else { |
416 | 416 | $array = $obj; |
417 | 417 | } |
418 | 418 | |
419 | - if(is_array($array)) |
|
419 | + if (is_array($array)) |
|
420 | 420 | { |
421 | - for($i = 0, $k = count($array); $i<$k; ++$i) |
|
421 | + for ($i = 0, $k = count($array); $i < $k; ++$i) |
|
422 | 422 | { |
423 | 423 | $key = key($array); |
424 | 424 | if ($key !== null |
@@ -448,10 +448,10 @@ discard block |
||
448 | 448 | public function getCurrencies() |
449 | 449 | { |
450 | 450 | static $arr; |
451 | - if($arr === null) |
|
451 | + if ($arr === null) |
|
452 | 452 | { |
453 | 453 | $arr = $this->findInfo('Currencies', 'Currencies'); |
454 | - foreach($arr as $k => $v) |
|
454 | + foreach ($arr as $k => $v) |
|
455 | 455 | $arr[$k] = $this->simplify($v); |
456 | 456 | } |
457 | 457 | return $arr; |
@@ -482,15 +482,15 @@ discard block |
||
482 | 482 | public function getTimeZones() |
483 | 483 | { |
484 | 484 | static $arr; |
485 | - if($arr === null) |
|
485 | + if ($arr === null) |
|
486 | 486 | { |
487 | 487 | $validPrefixes = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Etc', 'Europe', 'Indian', 'Pacific'); |
488 | 488 | $tmp = $this->findInfo('zoneStrings', 'zoneStrings'); |
489 | - foreach($tmp as $k => $v) |
|
489 | + foreach ($tmp as $k => $v) |
|
490 | 490 | { |
491 | - foreach($validPrefixes as $prefix) |
|
491 | + foreach ($validPrefixes as $prefix) |
|
492 | 492 | { |
493 | - if(strpos($k, $prefix) === 0) |
|
493 | + if (strpos($k, $prefix) === 0) |
|
494 | 494 | { |
495 | 495 | $arr[] = str_replace(':', '/', $k); |
496 | 496 | break; |