You are here

class CurrencyFormatter in Currency 7.2

Formats a currency according CLDR number pattern guidelines.

Hierarchy

Expanded class hierarchy of CurrencyFormatter

2 files declare their use of CurrencyFormatter
CurrencyFormatterTest.php in currency/vendor/bartfeenstra/cldr/src/BartFeenstra/Tests/CLDR/CurrencyFormatterTest.php
Contains class \BartFeenstra\Tests\CLDR\CurrencyFormatterTest.
CurrencyLocalePattern.inc in currency/includes/CurrencyLocalePattern.inc
Contains class CurrencyLocalePattern.

File

currency/vendor/bartfeenstra/cldr/src/BartFeenstra/CLDR/CurrencyFormatter.php, line 13
Contains class \BartFeenstra\CLDR\CurrencyFormatter.

Namespace

BartFeenstra\CLDR
View source
class CurrencyFormatter extends DecimalFormatter {

  /**
   * The currency's symbol.
   *
   * @var string
   */
  const SYMBOL_SPECIAL_CURRENCY = '¤';

  /**
   * Overrides parent::replacePlaceholders()
   */
  function replacePlaceholders(array $symbols, array $replacements = array()) {
    parent::replacePlaceholders($symbols, array(
      self::SYMBOL_SPECIAL_CURRENCY,
    ));
  }

  /**
   * Overrides parent::format().
   *
   * @param float|string $number
   * @param string $currency_sign
   *   An ISO 4217 code or currency sign.
   */
  public function format($number, $currency_sign = NULL) {
    $this->symbol_replacements[self::SYMBOL_SPECIAL_CURRENCY] = $currency_sign;
    return parent::format($number);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CurrencyFormatter::format public function Overrides parent::format(). Overrides DecimalFormatter::format
CurrencyFormatter::replacePlaceholders function Overrides parent::replacePlaceholders() Overrides IntegerFormatter::replacePlaceholders
CurrencyFormatter::SYMBOL_SPECIAL_CURRENCY constant The currency's symbol.
DecimalFormatter::cloneNumberPatternSymbols function Clones this formatter's NumberPatternSymbol objects. Overrides IntegerFormatter::cloneNumberPatternSymbols
DecimalFormatter::MAJOR constant Indicates a major pattern fragment.
DecimalFormatter::MINOR constant Indicates a minor pattern fragment.
DecimalFormatter::SYMBOL_SPECIAL_DECIMAL_SEPARATOR constant The decimal separator's symbol.
DecimalFormatter::__construct function Overrides parent::__construct(). Overrides IntegerFormatter::__construct
IntegerFormatter::$pattern public property The original pattern.
IntegerFormatter::$symbols protected property This pattern's symbols.
IntegerFormatter::$symbol_replacements public property Replacements for occurrences of the self::SYMBOL_SPECIAL_* constants in $this->pattern.
IntegerFormatter::getReplacement function Gets a replacement symbol for a placeholder.
IntegerFormatter::NEGATIVE constant Indicates a negative pattern.
IntegerFormatter::patternSymbols function Converts a number pattern to an array of NumberPatternSymbol objects.
IntegerFormatter::patternSymbolsSplit protected function Splits a pattern into two fragments.
IntegerFormatter::PCRE_META_CHARACTERS constant PCRE meta characters.
IntegerFormatter::POSITIVE constant Indicates a positive pattern.
IntegerFormatter::process protected function Process the pattern's symbols using a number.
IntegerFormatter::strrev static function Reverses a string in a unicode-safe way.
IntegerFormatter::str_split static function Splits a string in a unicode-safe way.
IntegerFormatter::symbolIsSpecial function Checks if a symbol is a special.
IntegerFormatter::SYMBOL_DIGIT constant A digit.
IntegerFormatter::SYMBOL_DIGIT_OPTIONAL constant An optional digit.
IntegerFormatter::SYMBOL_ESCAPE constant An escape character.
IntegerFormatter::SYMBOL_PATTERN_SEPARATOR constant The pattern separator.
IntegerFormatter::SYMBOL_SPECIAL_GROUPING_SEPARATOR constant The grouping separator's symbol.
IntegerFormatter::SYMBOL_SPECIAL_INFINITY constant Infinity's symbol.
IntegerFormatter::SYMBOL_SPECIAL_MINUS constant The minus sign's symbol.
IntegerFormatter::SYMBOL_SPECIAL_NAN constant "not a number"'s symbol.
IntegerFormatter::SYMBOL_SPECIAL_PLUS constant The plus sign's symbol.
IntegerFormatter::__clone function Implements __clone().