Convert a numeric value to a localized string.

@param int|float $data

@throws DataTransformerException

@return string
549207
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);
    }
744975
public function convertToString($data) {
		if (!is_string($data)) {
			$data = @json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
			// Removing null byte and double slashes from object properties
			$data = str_replace(['\\u0000', '\\\\'], ["", "\\"], $data);
		}

		return $data;
	}
610665
@Transformer(requireTemplate = true)
    public static String formatCurrency(Object data) {
        return formatCurrency(null, data, null, null);
    }
1320070
public static function toString($data)
    {
        if (is_array($data)) {
            $newData = [];
            foreach ($data as $key => $val) {
                $key = (string)$key;
                $newData[$key] = static::toString($val);
            }
        } else {
            $newData = (string)$data;
        }

        return $newData;
    }
619229
public function encodeInteger(int $data): string
    {
        $data = [$data];

        $converted = $this->baseConvert($data, 256, 62);

        return implode("", array_map(function ($index) {
            return $this->options["characters"][$index];
        }, $converted));
    }
887049
public function transform($data)
    {
        if (!is_null($data)) {
            return array($this->formTypeName => $this->entityDbMapper->fromDbToEntity($data)->getId());
        }

        return null;
    }
890723
private function doEncode($data = null)
    {
        $data = is_null($data) ? $this->data : $data;

        if (is_array($data) && (isset ($data[0]) || empty ($data))) {
            return $this->encodeList($data);
        } elseif (is_array($data)) {
            return $this->encodeDict($data);
        } elseif (is_integer($data) || is_float($data)) {
            $data = sprintf("%.0f", round($data, 0));
            return $this->encodeInteger($data);
        } else {
            return $this->encodeString($data);
        }
    }
312210
protected function _arrayToString($data)
    {
        $fields = array();
        foreach($data as $value)
        {
            //Implode array's
            if(is_array($value)) {
                $value = implode(',', $value);
            }

             // Escape the quote character within the field (e.g. " becomes "")
            if ($this->_quoteValue($value))
            {
                $quoted_value = str_replace($this->quote, $this->quote.$this->quote, $value);
                $fields[] 	  = $this->quote . $quoted_value . $this->quote;
            }
            else $fields[] = $value;
        }

        return  implode($this->separator, $fields);
    }
731935
protected function encodeMessageBody($data)
    {
        switch ($this->contentType) {
            case 'application/json':
                return json_encode($data);
            case 'application/x-httpd-php-source':
                return var_export($data, true);
            case 'vnd.php.serialized':
                return serialize($data);
            default:
                throw new \UnexpectedValueException("Serialization format unsupported: " . $this->contentType);
        }
    }
289559
public function encode($data): string
    {
        $encoded = \json_encode($data, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE);
        if (\json_last_error() !== JSON_ERROR_NONE) {
            throw new EncodingException(\json_last_error_msg());
        }
        return $encoded;
    }
98091
public function transform($value): string
    {
        if (null === $value || '' === $value) {
            return '';
        }

        if (!is_numeric($value)) {
            throw new TransformationFailedException('Expected a numeric or null.');
        }

        if ($value >= PHP_INT_MAX || $value <= -PHP_INT_MAX) {
            throw new TransformationFailedException('I don\'t have a clear idea what infinity looks like.');
        }

        return (string) $this->round($value);
    }
622270
private function convertString($data, &$cnt)
    {
        $len = strlen($data);
        $cnt+=$len+2;
        $retval = chr($len>>8).chr($len&0xff).$data;
        return $retval;
    }
1148135
protected function formatData(array $data) : string {
    $data_string = '';

    foreach ($data as $column => $value) {
      $data_string .= "`{$column}` = :{$column}";

      if (next($data) !== false) {
        $data_string .= ', ';
      }
    }

    return $data_string;
  }
1182029
protected function convertValue($data)
    {
        if ($this->isTraversable($data)) {
            return $this->recursiveConvertArray($data);
        }

        if (is_object($data)) {
            return $this->convertObject($data) ?: null;
        }

        return $data;
    }
528809
protected function convertEncoding($data)
    {
        if ($this->getEncodingInput() == $this->getEncodingOutput()) {
            return $data;
        }

        if (is_null($data)) {
            return $data;
        }

        if (is_array($data)) {
            foreach ($data as $key => $value) {
                $data[$key] = $this->convertEncoding($value);
            }

            return $data;
        }

        if ($this->getEncodingOutput() == 'UTF-8') {
            return utf8_encode($data);
        }

        return utf8_decode($data);
    }
329995
protected function encode($data)
    {
        if(null === $this->formatHandlerClass)
        {
            return $data;
        }
        else if(RequestContext::exsits() && null !== RequestContext::getServer())
        {
            return RequestContext::getServerBean($this->formatHandlerClass)->encode($data);
        }
        else
        {
            return App::getBean($this->formatHandlerClass)->encode($data);
        }
    }
1171957
private function encodeInteger($data = null)
    {
        $data = is_null($data) ? $this->data : $data;
        return sprintf("i%.0fe", $data);
    }