4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Intl\ResourceBundle
;
15 * Default implementation of {@link CurrencyBundleInterface}.
17 * @author Bernhard Schussek <bschussek@gmail.com>
19 class CurrencyBundle
extends AbstractBundle
implements CurrencyBundleInterface
23 const INDEX_SYMBOL
= 1;
25 const INDEX_FRACTION_DIGITS
= 2;
27 const INDEX_ROUNDING_INCREMENT
= 3;
32 public function getCurrencySymbol($currency, $locale = null)
34 if (null === $locale) {
35 $locale = \Locale
::getDefault();
38 return $this->readEntry($locale, array('Currencies', $currency, static::INDEX_SYMBOL
));
44 public function getCurrencyName($currency, $locale = null)
46 if (null === $locale) {
47 $locale = \Locale
::getDefault();
50 return $this->readEntry($locale, array('Currencies', $currency, static::INDEX_NAME
));
56 public function getCurrencyNames($locale = null)
58 if (null === $locale) {
59 $locale = \Locale
::getDefault();
62 if (null === ($currencies = $this->readEntry($locale, array('Currencies')))) {
66 if ($currencies instanceof \Traversable
) {
67 $currencies = iterator_to_array($currencies);
70 $index = static::INDEX_NAME
;
72 array_walk($currencies, function (&$value) use ($index) {
73 $value = $value[$index];
82 public function getFractionDigits($currency)
84 return $this->readEntry('en', array('Currencies', $currency, static::INDEX_FRACTION_DIGITS
));
90 public function getRoundingIncrement($currency)
92 return $this->readEntry('en', array('Currencies', $currency, static::INDEX_ROUNDING_INCREMENT
));