RegionBundle.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Intl\ResourceBundle;
  11. /**
  12. * Default implementation of {@link RegionBundleInterface}.
  13. *
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. */
  16. class RegionBundle extends AbstractBundle implements RegionBundleInterface
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public function getCountryName($country, $locale = null)
  22. {
  23. if (null === $locale) {
  24. $locale = \Locale::getDefault();
  25. }
  26. return $this->readEntry($locale, array('Countries', $country), true);
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function getCountryNames($locale = null)
  32. {
  33. if (null === $locale) {
  34. $locale = \Locale::getDefault();
  35. }
  36. if (null === ($countries = $this->readEntry($locale, array('Countries'), true))) {
  37. return array();
  38. }
  39. if ($countries instanceof \Traversable) {
  40. $countries = iterator_to_array($countries);
  41. }
  42. return $countries;
  43. }
  44. }