[HttpClient] add missing argument check

This commit is contained in:
Nicolas Grekas 2019-05-19 10:47:09 -03:00
parent 4559a656cc
commit 964acd9110
1 changed files with 4 additions and 0 deletions

View File

@ -36,6 +36,10 @@ class ScopingHttpClient implements HttpClientInterface
$this->client = $client;
$this->defaultOptionsByRegexp = $defaultOptionsByRegexp;
$this->defaultRegexp = $defaultRegexp;
if (null !== $defaultRegexp && !isset($defaultOptionsByRegexp[$defaultRegexp])) {
throw new InvalidArgumentException(sprintf('No options are mapped to the provided "%s" default regexp.', $defaultRegexp));
}
}
public static function forBaseUri(HttpClientInterface $client, string $baseUri, array $defaultOptions = [], $regexp = null): self