Currencies.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\Polyfill\Intl\Icu;
  11. /**
  12. * @author Nicolas Grekas <p@tchwork.com>
  13. *
  14. * @internal
  15. */
  16. class Currencies
  17. {
  18. private static $data;
  19. public static function getSymbol(string $currency): ?string
  20. {
  21. $data = self::$data ?? self::$data = require __DIR__.'/Resources/currencies.php';
  22. return $data[$currency][0] ?? $data[strtoupper($currency)][0] ?? null;
  23. }
  24. public static function getFractionDigits(string $currency): int
  25. {
  26. $data = self::$data ?? self::$data = require __DIR__.'/Resources/currencies.php';
  27. return $data[$currency][1] ?? $data[strtoupper($currency)][1] ?? $data['DEFAULT'][1];
  28. }
  29. public static function getRoundingIncrement(string $currency): int
  30. {
  31. $data = self::$data ?? self::$data = require __DIR__.'/Resources/currencies.php';
  32. return $data[$currency][2] ?? $data[strtoupper($currency)][2] ?? $data['DEFAULT'][2];
  33. }
  34. }