argumentMap = $argumentMap; } /** * Do a GET request to retrieve the contents of a remote URL. * * @param string $url URL to get. * @return Response Response for the executed request. * @throws FailedRemoteRequest If retrieving the contents from the URL failed. */ public function get($url) { if (! array_key_exists($url, $this->argumentMap)) { throw new LogicException("Trying to get a remote request from the filesystem for an unknown URL: {$url}."); } if (! file_exists($this->argumentMap[$url]) || ! is_readable($this->argumentMap[$url])) { throw new LogicException( 'Trying to get a remote request from the filesystem for a file that is not accessible: ' . "{$url} => {$this->argumentMap[$url]}." ); } try { return new RemoteGetRequestResponse(file_get_contents($this->argumentMap[$url])); } catch (Exception $exception) { throw FailedToGetFromRemoteUrl::withException($url, $exception); } } }