You are here

public function HttpClientBaseFormatter::serialize in Http Client 6.2

Same name and namespace in other branches
  1. 7.2 includes/HttpClient.inc \HttpClientBaseFormatter::serialize()

Serializes arbitrary data.

Parameters

mixed $data: The data that should be serialized.

Return value

string The serialized data as a string.

Overrides HttpClientFormatter::serialize

File

includes/HttpClient.inc, line 322

Class

HttpClientBaseFormatter
A base formatter to format php and json.

Code

public function serialize($data) {
  switch ($this->format) {
    case self::FORMAT_PHP:
      return serialize($data);
      break;
    case self::FORMAT_JSON:
      return json_encode($data);
      break;
    case self::FORMAT_FORM:
      return http_build_query($data, NULL, '&');
      break;
  }
}