public function transform($value)
    {
        if (null === $value) {
            return '';
        }

        if (!is_numeric($value)) {
            throw new UnexpectedTypeException($value, 'numeric');
        }

        $formatter = $this->getNumberFormatter(\NumberFormatter::CURRENCY);
        $value /= $this->divisor;

        if (null !== $this->currency) {
            $value = $formatter->formatCurrency($value, $this->currency);
        } else {
            $value = $formatter->format($value);
        }

        if (0 !== $formatter->getErrorCode()) {
            throw new TransformationFailedException($formatter->getErrorMessage());
        }

        return $value;
    }
public function transform($value)
    {
        if (null === $value) {
            return '';
        }

        if (!is_numeric($value)) {
            throw new UnexpectedTypeException($value, 'numeric');
        }

        $formatter = $this->getNumberFormatter(\NumberFormatter::CURRENCY);
        $value /= $this->divisor;

        if (null !== $this->currency) {
            $value = $formatter->formatCurrency($value, $this->currency);
        } else {
            $value = $formatter->format($value);
        }

        if (0 !== $formatter->getErrorCode()) {
            throw new TransformationFailedException($formatter->getErrorMessage());
        }

        return $value;
    }
public function transform ( $ value ) { if ( null === $ value ) { return '' ; } if ( ! is_numeric ( $ value ) ) { throw new UnexpectedTypeException ( $ value , 'numeric' ) ; } $ formatter = $ this -> getNumberFormatter ( \ NumberFormatter :: CURRENCY ) ; $ value /= $ this -> divisor ; if ( null !== $ this -> currency ) { $ value = $ formatter -> formatCurrency ( $ value , $ this -> currency ) ; } else { $ value = $ formatter -> format ( $ value ) ; } if ( 0 !== $ formatter -> getErrorCode ( ) ) { throw new TransformationFailedException ( $ formatter -> getErrorMessage ( ) ) ; } return $ value ; }
Transforms a number type into localized money.

@param int|float $value Number value

@return string Localized value

@throws UnexpectedTypeException       if the given value is not numeric
@throws TransformationFailedException if the value can not be transformed
Transforms a number type into localized money .