/** * Create service with name * * @param ServiceLocatorInterface $serviceLocator * @param $name * @param $requestedName * @return mixed */ public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) { $allConfigs = $this->getConfig($serviceLocator); $config = $allConfigs[$requestedName]; $httpClient = new HttpClient(); if (isset($config['http_client_options'])) { $httpClient->setOptions($config['http_client_options']); } $client = new Client($httpClient, $config['base_uri']); if (isset($config['default_headers'])) { $client->setDefaultHeaders($config['default_headers']); } if (isset($config['throw_exceptions'])) { $client->setThrowExceptions($config['throw_exceptions']); } return $client; }