public function HttpClientBaseFormatter::unserialize in Http Client 6.2
Same name and namespace in other branches
- 7.2 includes/HttpClient.inc \HttpClientBaseFormatter::unserialize()
Unserializes data.
Parameters
string $data: The data that should be unserialized.
Return value
mixed The unserialized data.
Overrides HttpClientFormatter::unserialize
File
- includes/
HttpClient.inc, line 344
Class
- HttpClientBaseFormatter
- A base formatter to format php and json.
Code
public function unserialize($data) {
switch ($this->format) {
case self::FORMAT_PHP:
if (($response = @unserialize($data)) !== FALSE || $data === serialize(FALSE)) {
return $response;
}
else {
throw new Exception(t('Unserialization of response body failed.'), 1);
}
break;
case self::FORMAT_JSON:
$response = json_decode($data);
if ($response === NULL) {
throw new Exception(t('Unserialization of response body failed.'), 1);
}
return $response;
break;
case self::FORMAT_FORM:
$response = array();
parse_str($data, $response);
return $response;
break;
}
}