* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Intl\Data\Provider; use Symfony\Component\Intl\Exception\MissingResourceException; use Symfony\Component\Intl\Locale; use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; /** * Data provider for currency-related data. * * @author Bernhard Schussek * * @internal */ class CurrencyDataProvider { const INDEX_SYMBOL = 0; const INDEX_NAME = 1; const INDEX_FRACTION_DIGITS = 0; const INDEX_ROUNDING_INCREMENT = 1; private $path; private $reader; /** * Creates a data provider that reads currency-related data from a * resource bundle. * * @param string $path The path to the resource bundle * @param BundleEntryReaderInterface $reader The reader for reading the resource bundle */ public function __construct($path, BundleEntryReaderInterface $reader) { $this->path = $path; $this->reader = $reader; } public function getCurrencies() { return $this->reader->readEntry($this->path, 'meta', array('Currencies')); } public function getSymbol($currency, $displayLocale = null) { if (null === $displayLocale) { $displayLocale = Locale::getDefault(); } return $this->reader->readEntry($this->path, $displayLocale, array('Names', $currency, static::INDEX_SYMBOL)); } public function getName($currency, $displayLocale = null) { if (null === $displayLocale) { $displayLocale = Locale::getDefault(); } return $this->reader->readEntry($this->path, $displayLocale, array('Names', $currency, static::INDEX_NAME)); } public function getNames($displayLocale = null) { if (null === $displayLocale) { $displayLocale = Locale::getDefault(); } // ==================================================================== // For reference: It is NOT possible to return names indexed by // numeric code here, because some numeric codes map to multiple // 3-letter codes (e.g. 32 => "ARA", "ARP", "ARS") // ==================================================================== $names = $this->reader->readEntry($this->path, $displayLocale, array('Names')); if ($names instanceof \Traversable) { $names = iterator_to_array($names); } $index = static::INDEX_NAME; array_walk($names, function (&$value) use ($index) { $value = $value[$index]; }); // Sorting by value cannot be done during bundle generation, because // binary bundles are always sorted by keys $collator = new \Collator($displayLocale); $collator->asort($names); return $names; } /** * Data provider for {@link \Symfony\Component\Intl\Currency::getFractionDigits()}. */ public function getFractionDigits($currency) { try { return $this->reader->readEntry($this->path, 'meta', array('Meta', $currency, static::INDEX_FRACTION_DIGITS)); } catch (MissingResourceException $e) { return $this->reader->readEntry($this->path, 'meta', array('Meta', 'DEFAULT', static::INDEX_FRACTION_DIGITS)); } } /** * Data provider for {@link \Symfony\Component\Intl\Currency::getRoundingIncrement()}. */ public function getRoundingIncrement($currency) { try { return $this->reader->readEntry($this->path, 'meta', array('Meta', $currency, static::INDEX_ROUNDING_INCREMENT)); } catch (MissingResourceException $e) { return $this->reader->readEntry($this->path, 'meta', array('Meta', 'DEFAULT', static::INDEX_ROUNDING_INCREMENT)); } } /** * Data provider for {@link \Symfony\Component\Intl\Currency::getNumericCode()}. */ public function getNumericCode($currency) { return $this->reader->readEntry($this->path, 'meta', array('Alpha3ToNumeric', $currency)); } /** * Data provider for {@link \Symfony\Component\Intl\Currency::forNumericCode()}. */ public function forNumericCode($numericCode) { return $this->reader->readEntry($this->path, 'meta', array('NumericToAlpha3', (string) $numericCode)); } } __halt_compiler();----SIGNATURE:----tcGcx29Sy32DR2AeB5ehikblUHnMZDbFBdgERErtvkt6bMwrIGLXmeGhTx8QND37CpprVl6nfCCq2HkvzooxmZDPZu3B5C7yiWhoC45u2KYSQ6MTPfn19aROBN3N0R0W5zqLFpkfZoKhMOftQeI+ieDXJeC2U7XOUoxAeZODmy4t1f+hS+fIKxwQYC6q/7r46y447Eu1IcB1OgthStBR3/CqkoBd0Oq9LdEWFB4dwWBG3vriPpdTTxG8dM+yEtIgzJ/mPHhsOLxeG8PrdyYZAFAr5yb9NMRGBBzIwXvBZwKtYfhYFJdJexVtMVS7id6ZyUE7DSJI8FXSbSh8v/gwfx2c9E0M1xEJn7ZXfUcVH+9BHdVzWRuihjWlKpkKLgaI0VJjoY8z4vjf+V9FUHf32Q8bxvvZXHC5Pg2pKEXCy93yCS7fGphFV7Vv5I4UrBJNDMs+yNpISOPh/+Q/54ZgPe+/kRsRvxMWqAJGb+Ihy4UomvZ7Uh3RSn1kX459L5hgiVwyidPwmDFi3VOnEn88W92n4KDqHGiIL4Yxrbs5inYdo3kSbNmqJzfF1vuM2gMsrQfLKw4Uc/gfL16rGeETQ3poHmu/vqsyQ88nnTGrUXrDxlqsfLpJ7lkHxWlbBbqEYPU/S2RsmrS4Hj78fbBr7hFGPkggROJ9CBzf6xjBjaM=----ATTACHMENT:----MTE3NjU0Njc0NTg4NDU5MyA0NDkyNTQ5OTI4MjI2MTU1IDIyNjU5MzQ4OTg2MzU0Mjc=