/** * Applies the listeners needed to parse client models. * * @param Service $api API to create a parser for * @return callable * @throws \UnexpectedValueException */ public static function createParser(Service $api) { static $mapping = ['json' => 'ILAB_Aws\\Api\\Parser\\JsonRpcParser', 'query' => 'ILAB_Aws\\Api\\Parser\\QueryParser', 'rest-json' => 'ILAB_Aws\\Api\\Parser\\RestJsonParser', 'rest-xml' => 'ILAB_Aws\\Api\\Parser\\RestXmlParser']; $proto = $api->getProtocol(); if (isset($mapping[$proto])) { return new $mapping[$proto]($api); } elseif ($proto == 'ec2') { return new QueryParser($api, null, false); } throw new \UnexpectedValueException('Unknown protocol: ' . $api->getProtocol()); }