@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | */ |
199 | 199 | protected function getFormatter($culture, $type) |
200 | 200 | { |
201 | - if(!isset(self::$formatters[$culture])) |
|
201 | + if (!isset(self::$formatters[$culture])) |
|
202 | 202 | self::$formatters[$culture] = []; |
203 | - if(!isset(self::$formatters[$culture][$type])) |
|
203 | + if (!isset(self::$formatters[$culture][$type])) |
|
204 | 204 | self::$formatters[$culture][$type] = new \NumberFormatter($culture, $type); |
205 | 205 | |
206 | 206 | return self::$formatters[$culture][$type]; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $type = $this->getType(); |
225 | 225 | $pattern = $this->getPattern(); |
226 | 226 | |
227 | - if(empty($pattern)) |
|
227 | + if (empty($pattern)) |
|
228 | 228 | { |
229 | 229 | $formatter = $this->getFormatter($culture, $type); |
230 | 230 | } else { |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $formatter->setPattern($pattern); |
233 | 233 | } |
234 | 234 | |
235 | - if($type === \NumberFormatter::CURRENCY) |
|
235 | + if ($type === \NumberFormatter::CURRENCY) |
|
236 | 236 | { |
237 | 237 | $result = $formatter->formatCurrency($this->getValue(), $this->getCurrency()); |
238 | 238 | } else { |
@@ -253,24 +253,24 @@ discard block |
||
253 | 253 | $current_part = $culture_parts[0]; |
254 | 254 | |
255 | 255 | $culturesToLoad = [$current_part]; |
256 | - for($i = 1, $k = count($culture_parts); $i < $k; ++$i) |
|
256 | + for ($i = 1, $k = count($culture_parts); $i < $k; ++$i) |
|
257 | 257 | { |
258 | - $current_part .= '_'.$culture_parts[$i]; |
|
258 | + $current_part .= '_' . $culture_parts[$i]; |
|
259 | 259 | $culturesToLoad[] = $current_part; |
260 | 260 | } |
261 | 261 | |
262 | - foreach(self::$bundleNames as $key => $bundleName) |
|
262 | + foreach (self::$bundleNames as $key => $bundleName) |
|
263 | 263 | { |
264 | - if(!array_key_exists($key, $this->data)) |
|
264 | + if (!array_key_exists($key, $this->data)) |
|
265 | 265 | $this->data[$key] = []; |
266 | 266 | } |
267 | - foreach($culturesToLoad as $culture) |
|
267 | + foreach ($culturesToLoad as $culture) |
|
268 | 268 | { |
269 | - if(in_array($culture, $this->resourceBundles)) |
|
269 | + if (in_array($culture, $this->resourceBundles)) |
|
270 | 270 | continue; |
271 | 271 | |
272 | 272 | array_unshift($this->resourceBundles, $culture); |
273 | - foreach(self::$bundleNames as $key => $bundleName) |
|
273 | + foreach (self::$bundleNames as $key => $bundleName) |
|
274 | 274 | { |
275 | 275 | $this->data[$key][$culture] = \ResourceBundle::create($culture, $bundleName, false); |
276 | 276 | } |
@@ -291,17 +291,17 @@ discard block |
||
291 | 291 | * @param bool $merge merge the data from its parents. |
292 | 292 | * @return mixed the specific ICU data. |
293 | 293 | */ |
294 | - public function findInfo($path='/', $merge=false, $key = null) |
|
294 | + public function findInfo($path = '/', $merge = false, $key = null) |
|
295 | 295 | { |
296 | 296 | $result = []; |
297 | 297 | |
298 | - if($key === null) |
|
298 | + if ($key === null) |
|
299 | 299 | { |
300 | 300 | // try to guess the bundle from the path. Always defaults to "Core". |
301 | 301 | $key = 'Core'; |
302 | - foreach(self::$bundleNames as $bundleName => $icuBundleName) |
|
302 | + foreach (self::$bundleNames as $bundleName => $icuBundleName) |
|
303 | 303 | { |
304 | - if(strpos($path, $bundleName) === 0) |
|
304 | + if (strpos($path, $bundleName) === 0) |
|
305 | 305 | { |
306 | 306 | $key = $bundleName; |
307 | 307 | break; |
@@ -309,17 +309,17 @@ discard block |
||
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
312 | - if(!array_key_exists($key, $this->data)) |
|
312 | + if (!array_key_exists($key, $this->data)) |
|
313 | 313 | return $result; |
314 | - foreach($this->resourceBundles as $culture) |
|
314 | + foreach ($this->resourceBundles as $culture) |
|
315 | 315 | { |
316 | 316 | $res = $this->data[$key][$culture]; |
317 | - if($res === null) |
|
317 | + if ($res === null) |
|
318 | 318 | continue; |
319 | 319 | $info = $this->searchResources($res, $path); |
320 | - if($info) |
|
320 | + if ($info) |
|
321 | 321 | { |
322 | - if($merge) |
|
322 | + if ($merge) |
|
323 | 323 | $result = array_merge($result, $info); |
324 | 324 | else |
325 | 325 | return $info; |
@@ -337,16 +337,16 @@ discard block |
||
337 | 337 | * @param string $path slash "/" separated array path. |
338 | 338 | * @return mixed the value array using the path |
339 | 339 | */ |
340 | - private function searchResources($info, $path='/') |
|
340 | + private function searchResources($info, $path = '/') |
|
341 | 341 | { |
342 | 342 | $index = explode('/', $path); |
343 | 343 | |
344 | 344 | $resource = $info; |
345 | - for($i = 0, $k = count($index); $i < $k; ++$i) |
|
345 | + for ($i = 0, $k = count($index); $i < $k; ++$i) |
|
346 | 346 | { |
347 | 347 | |
348 | 348 | $resource = $resource->get($index[$i], false); |
349 | - if($resource === null) |
|
349 | + if ($resource === null) |
|
350 | 350 | return null; |
351 | 351 | } |
352 | 352 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function getDateTimeFormat() |
372 | 372 | { |
373 | - if($this->dateTimeFormat === null) |
|
373 | + if ($this->dateTimeFormat === null) |
|
374 | 374 | { |
375 | 375 | $this->setDateTimeFormat(new DateTimeFormatInfo($this)); |
376 | 376 | } |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | $reg = substr($this->culture, 3, 2); |
409 | 409 | $language = $this->findInfo("Languages/{$lang}"); |
410 | 410 | $region = $this->findInfo("Countries/{$reg}"); |
411 | - if($region) |
|
412 | - return $language.' ('.$region.')'; |
|
411 | + if ($region) |
|
412 | + return $language . ' (' . $region . ')'; |
|
413 | 413 | else |
414 | 414 | return $language; |
415 | 415 | } |
@@ -432,8 +432,8 @@ discard block |
||
432 | 432 | } |
433 | 433 | |
434 | 434 | $region = $culture->findInfo("Countries/{$reg}"); |
435 | - if($region) |
|
436 | - return $language.' ('.$region.')'; |
|
435 | + if ($region) |
|
436 | + return $language . ' (' . $region . ')'; |
|
437 | 437 | else |
438 | 438 | return $language; |
439 | 439 | } |
@@ -489,25 +489,25 @@ discard block |
||
489 | 489 | * or CultureInfo::SPECIFIC. |
490 | 490 | * @return array list of culture information available. |
491 | 491 | */ |
492 | - public static function getCultures($type=CultureInfo::ALL) |
|
492 | + public static function getCultures($type = CultureInfo::ALL) |
|
493 | 493 | { |
494 | 494 | $all = \ResourceBundle::getLocales(''); |
495 | 495 | |
496 | - switch($type) |
|
496 | + switch ($type) |
|
497 | 497 | { |
498 | 498 | case CultureInfo::ALL : |
499 | 499 | return $all; |
500 | 500 | case CultureInfo::NEUTRAL : |
501 | - foreach($all as $key => $culture) |
|
501 | + foreach ($all as $key => $culture) |
|
502 | 502 | { |
503 | - if(strlen($culture) != 2) |
|
503 | + if (strlen($culture) != 2) |
|
504 | 504 | unset($all[$key]); |
505 | 505 | } |
506 | 506 | return $all; |
507 | 507 | case CultureInfo::SPECIFIC : |
508 | - foreach($all as $key => $culture) |
|
508 | + foreach ($all as $key => $culture) |
|
509 | 509 | { |
510 | - if(strlen($culture) == 2) |
|
510 | + if (strlen($culture) == 2) |
|
511 | 511 | unset($all[$key]); |
512 | 512 | } |
513 | 513 | return $all; |
@@ -523,17 +523,17 @@ discard block |
||
523 | 523 | */ |
524 | 524 | protected function simplify($obj) |
525 | 525 | { |
526 | - if(is_scalar($obj)) { |
|
526 | + if (is_scalar($obj)) { |
|
527 | 527 | return $obj; |
528 | - } elseif($obj instanceof \ResourceBundle) { |
|
528 | + } elseif ($obj instanceof \ResourceBundle) { |
|
529 | 529 | $array = array(); |
530 | - foreach($obj as $k => $v) |
|
530 | + foreach ($obj as $k => $v) |
|
531 | 531 | $array[$k] = $v; |
532 | 532 | } else { |
533 | 533 | $array = $obj; |
534 | 534 | } |
535 | 535 | |
536 | - for($i = 0, $k = count($array); $i<$k; ++$i) |
|
536 | + for ($i = 0, $k = count($array); $i < $k; ++$i) |
|
537 | 537 | { |
538 | 538 | $key = key($array); |
539 | 539 | if (is_array($array[$key]) |
@@ -561,10 +561,10 @@ discard block |
||
561 | 561 | public function getCurrencies() |
562 | 562 | { |
563 | 563 | static $arr; |
564 | - if($arr === null) |
|
564 | + if ($arr === null) |
|
565 | 565 | { |
566 | 566 | $arr = $this->findInfo('Currencies', true, 'Currencies'); |
567 | - foreach($arr as $k => $v) |
|
567 | + foreach ($arr as $k => $v) |
|
568 | 568 | $arr[$k] = $this->simplify($v); |
569 | 569 | } |
570 | 570 | return $arr; |
@@ -595,15 +595,15 @@ discard block |
||
595 | 595 | public function getTimeZones() |
596 | 596 | { |
597 | 597 | static $arr; |
598 | - if($arr === null) |
|
598 | + if ($arr === null) |
|
599 | 599 | { |
600 | 600 | $validPrefixes = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Etc', 'Europe', 'Indian', 'Pacific'); |
601 | 601 | $tmp = $this->findInfo('zoneStrings', true, 'zoneStrings'); |
602 | - foreach($tmp as $k => $v) |
|
602 | + foreach ($tmp as $k => $v) |
|
603 | 603 | { |
604 | - foreach($validPrefixes as $prefix) |
|
604 | + foreach ($validPrefixes as $prefix) |
|
605 | 605 | { |
606 | - if(strpos($k, $prefix) === 0) |
|
606 | + if (strpos($k, $prefix) === 0) |
|
607 | 607 | { |
608 | 608 | $arr[] = str_replace(':', '/', $k); |
609 | 609 | break; |