public function format($number, ArrayObject $row = null): string
    {
        $locale = $this->params['locale'];

        //$formatterId = md5($locale);
        $formatterId = $locale . (string) $this->params['pattern'];

        if (!array_key_exists($formatterId, $this->formatters)) {
            $this->loadFormatterId($formatterId);
        }

        if ($this->currency_column !== null) {
            if (!isset($row[$this->currency_column])) {
                throw new Exception\RuntimeException(__METHOD__ . " Cannot determine currency code based on column '{$this->currency_column}'.");
            }
            $value = $this->formatters[$formatterId]->formatCurrency(
                (float) $number,
                $row[$this->currency_column]
            );
        } else {
            if ($this->params['currency_code'] == '') {
                throw new Exception\RuntimeException(__METHOD__ . ' Currency code must be set prior to use the currency formatter');
            }

            $value = $this->formatters[$formatterId]->formatCurrency(
                (float) $number,
                $this->params['currency_code']
            );
        }

        if (intl_is_failure($this->formatters[$formatterId]->getErrorCode())) {
            $this->throwNumberFormatterException($this->formatters[$formatterId], $number);
        }

        return $value;
    }
public function format($number, ArrayObject $row = null): string
    {
        $locale = $this->params['locale'];

        //$formatterId = md5($locale);
        $formatterId = $locale . (string) $this->params['pattern'];

        if (!array_key_exists($formatterId, $this->formatters)) {
            $this->loadFormatterId($formatterId);
        }

        if ($this->currency_column !== null) {
            if (!isset($row[$this->currency_column])) {
                throw new Exception\RuntimeException(__METHOD__ . " Cannot determine currency code based on column '{$this->currency_column}'.");
            }
            $value = $this->formatters[$formatterId]->formatCurrency(
                (float) $number,
                $row[$this->currency_column]
            );
        } else {
            if ($this->params['currency_code'] == '') {
                throw new Exception\RuntimeException(__METHOD__ . ' Currency code must be set prior to use the currency formatter');
            }

            $value = $this->formatters[$formatterId]->formatCurrency(
                (float) $number,
                $this->params['currency_code']
            );
        }

        if (intl_is_failure($this->formatters[$formatterId]->getErrorCode())) {
            $this->throwNumberFormatterException($this->formatters[$formatterId], $number);
        }

        return $value;
    }
public function format ( $ number , ArrayObject $ row = null ) : string { $ locale = $ this -> params [ 'locale' ] ; //$formatterId = md5($locale); $ formatterId = $ locale . ( string ) $ this -> params [ 'pattern' ] ; if ( ! array_key_exists ( $ formatterId , $ this -> formatters ) ) { $ this -> loadFormatterId ( $ formatterId ) ; } if ( $ this -> currency_column !== null ) { if ( ! isset ( $ row [ $ this -> currency_column ] ) ) { throw new Exception \ RuntimeException ( __METHOD__ . " Cannot determine currency code based on column '{$this->currency_column}'." ) ; } $ value = $ this -> formatters [ $ formatterId ] -> formatCurrency ( ( float ) $ number , $ row [ $ this -> currency_column ] ) ; } else { if ( $ this -> params [ 'currency_code' ] == '' ) { throw new Exception \ RuntimeException ( __METHOD__ . ' Currency code must be set prior to use the currency formatter' ) ; } $ value = $ this -> formatters [ $ formatterId ] -> formatCurrency ( ( float ) $ number , $ this -> params [ 'currency_code' ] ) ; } if ( intl_is_failure ( $ this -> formatters [ $ formatterId ] -> getErrorCode ( ) ) ) { $ this -> throwNumberFormatterException ( $ this -> formatters [ $ formatterId ] , $ number ) ; } return $ value ; }
Currency format a number.

@throws Exception\RuntimeException

@param float|string|int $number

@return string
Currency format a number .