public function request(string
$method, string
$url, array
$options =
[]): ResponseInterface
{ [$url,
$options] =
$this->
prepareRequest($method,
$url,
$options,
$this->defaultOptions, true
);
$url =
implode('',
$url);
if (null ===
$this->responseFactory
) { $response =
new MockResponse();
} elseif (\
is_callable($this->responseFactory
)) { $response =
($this->responseFactory
)($method,
$url,
$options);
} elseif (!
$this->responseFactory->
valid()) { throw new TransportException($this->requestsCount ? 'No more response left in the response factory iterator passed to MockHttpClient: the number of requests exceeds the number of responses.' : 'The response factory iterator passed to MockHttpClient is empty.'
);
} else { $responseFactory =
$this->responseFactory->
current();
$response = \
is_callable($responseFactory) ?
$responseFactory($method,
$url,
$options) :
$responseFactory;
$this->responseFactory->
next();
} ++
$this->requestsCount;
if (!
$response instanceof ResponseInterface
) { throw new TransportException(sprintf('The response factory passed to MockHttpClient must return/yield an instance of ResponseInterface, "%s" given.',
get_debug_type($response)));
}