protected function _parse($response, $format) { switch ($format) { case Format::json: return Json::parse($response); case Format::xml: return Xml::parse($response); default: throw new Exception('Unsupported response format.'); } }