public function formatCurrencyNumber($number, Locale $locale, $currency, $formatLength = NumbersReader::FORMAT_LENGTH_DEFAULT, $currencyCode = null)
    {
        NumbersReader::validateFormatLength($formatLength);
        $parsedFormat = $this->numbersReader->parseFormatFromCldr($locale, NumbersReader::FORMAT_TYPE_CURRENCY, $formatLength);

        if ($currencyCode !== null) {
            // When currencyCode is set, maxDecimalDigits and rounding is overridden with CLDR data
            $currencyFraction = $this->currencyReader->getFraction($currencyCode);
            $parsedFormat['rounding'] = $currencyFraction['rounding'];
            $parsedFormat['maxDecimalDigits'] = $currencyFraction['digits'];
            $parsedFormat['minDecimalDigits'] = min($parsedFormat['minDecimalDigits'], $parsedFormat['maxDecimalDigits']);
        }

        return $this->doFormattingWithParsedFormat($number, $parsedFormat, $this->numbersReader->getLocalizedSymbolsForLocale($locale), $currency);
    }
public function formatCurrencyNumber($number, Locale $locale, $currency, $formatLength = NumbersReader::FORMAT_LENGTH_DEFAULT, $currencyCode = null)
    {
        NumbersReader::validateFormatLength($formatLength);
        $parsedFormat = $this->numbersReader->parseFormatFromCldr($locale, NumbersReader::FORMAT_TYPE_CURRENCY, $formatLength);

        if ($currencyCode !== null) {
            // When currencyCode is set, maxDecimalDigits and rounding is overridden with CLDR data
            $currencyFraction = $this->currencyReader->getFraction($currencyCode);
            $parsedFormat['rounding'] = $currencyFraction['rounding'];
            $parsedFormat['maxDecimalDigits'] = $currencyFraction['digits'];
            $parsedFormat['minDecimalDigits'] = min($parsedFormat['minDecimalDigits'], $parsedFormat['maxDecimalDigits']);
        }

        return $this->doFormattingWithParsedFormat($number, $parsedFormat, $this->numbersReader->getLocalizedSymbolsForLocale($locale), $currency);
    }
public function formatCurrencyNumber ( $ number , Locale $ locale , $ currency , $ formatLength = NumbersReader :: FORMAT_LENGTH_DEFAULT , $ currencyCode = null ) { NumbersReader :: validateFormatLength ( $ formatLength ) ; $ parsedFormat = $ this -> numbersReader -> parseFormatFromCldr ( $ locale , NumbersReader :: FORMAT_TYPE_CURRENCY , $ formatLength ) ; if ( $ currencyCode !== null ) { // When currencyCode is set, maxDecimalDigits and rounding is overridden with CLDR data $ currencyFraction = $ this -> currencyReader -> getFraction ( $ currencyCode ) ; $ parsedFormat [ 'rounding' ] = $ currencyFraction [ 'rounding' ] ; $ parsedFormat [ 'maxDecimalDigits' ] = $ currencyFraction [ 'digits' ] ; $ parsedFormat [ 'minDecimalDigits' ] = min ( $ parsedFormat [ 'minDecimalDigits' ] , $ parsedFormat [ 'maxDecimalDigits' ] ) ; } return $ this -> doFormattingWithParsedFormat ( $ number , $ parsedFormat , $ this -> numbersReader -> getLocalizedSymbolsForLocale ( $ locale ) , $ currency ) ; }
Formats number with format string for currency defined in CLDR for
particular locale.

Currency symbol provided will be inserted into formatted number string.

Note: currently length is not used in currencyFormats from CLDR.
But it's defined in the specification, so we support it here.

@param mixed $number Float or int, can be negative, can be NaN or infinite
@param Locale $locale
@param string $currency Currency symbol (or name)
@param string $formatLength One of NumbersReader FORMAT_LENGTH constants
@param string $currencyCode The ISO 4217 currency code of the currency to format. Used to set decimal places and rounding.
@return string Formatted number. Will return string-casted version of $number if there is no pattern for given $locale / $formatLength
@api
Formats number with format string for currency defined in CLDR for particular locale .