src/Forms/Transformers/NumberToLocalizedStringTransformer.php
public function transform($data)
    {
        if (is_null($data) || '' === $data) {
            return '';
        }

        if (! is_numeric($data)) {
            throw new DataTransformerException('A numeric value is expected.');
        }

        $formatter = $this->getFormatter();

        $value =  $formatter->format($data);

        if (intl_is_failure($formatter->getErrorCode())) {
            throw new DataTransformerException($formatter->getErrorMessage());
        }

        // Convert fixed spaces to normal ones
        return str_replace("\xc2\xa0", ' ', $value);
    }
public function transform($data)
    {
        if (is_null($data) || '' === $data) {
            return '';
        }

        if (! is_numeric($data)) {
            throw new DataTransformerException('A numeric value is expected.');
        }

        $formatter = $this->getFormatter();

        $value =  $formatter->format($data);

        if (intl_is_failure($formatter->getErrorCode())) {
            throw new DataTransformerException($formatter->getErrorMessage());
        }

        // Convert fixed spaces to normal ones
        return str_replace("\xc2\xa0", ' ', $value);
    }
public function transform ( $ data ) { if ( is_null ( $ data ) || '' === $ data ) { return '' ; } if ( ! is_numeric ( $ data ) ) { throw new DataTransformerException ( 'A numeric value is expected.' ) ; } $ formatter = $ this -> getFormatter ( ) ; $ value = $ formatter -> format ( $ data ) ; if ( intl_is_failure ( $ formatter -> getErrorCode ( ) ) ) { throw new DataTransformerException ( $ formatter -> getErrorMessage ( ) ) ; } // Convert fixed spaces to normal ones return str_replace ( "\xc2\xa0" , ' ' , $ value ) ; }
Convert a numeric value to a localized string.

@param int|float $data

@throws DataTransformerException

@return string
Convert a numeric value to a localized string .