/** * Parse a response into a response type * * @static * @param string $data Response data to be parsed * @param string $type = 'xml' Response format * @return mixed Response object */ public static function response($data, $type = self::FORMAT_XML) { if (is_string($data) && strlen($data) === 0) { return true; // Many operations return an empty string for success } switch ($type) { case static::FORMAT_XML: return AbstractResponse::fromXml($data); case static::FORMAT_JSON: return AbstractResponse::fromJson($data); } throw new InvalidArgumentException("Type must be 'xml' or 'json'"); }