From fbc001c5ca8b12c6ffeb2b3d564b10b673e4ebb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1gi-Kaz=C3=A1r=20M=C3=A1rk?= Date: Mon, 26 Oct 2015 09:49:46 +0100 Subject: [PATCH] Remove multiple requests from HTTP Client Remove Batch related stuff (result, exception) Remove batch tests --- spec/Exception/BatchExceptionSpec.php | 36 --------- src/BatchResult.php | 103 -------------------------- src/Exception/BatchException.php | 39 ---------- src/HttpClient.php | 18 ----- 4 files changed, 196 deletions(-) delete mode 100644 spec/Exception/BatchExceptionSpec.php delete mode 100644 src/BatchResult.php delete mode 100644 src/Exception/BatchException.php diff --git a/spec/Exception/BatchExceptionSpec.php b/spec/Exception/BatchExceptionSpec.php deleted file mode 100644 index b90dd47..0000000 --- a/spec/Exception/BatchExceptionSpec.php +++ /dev/null @@ -1,36 +0,0 @@ -beConstructedWith($batchResult); - } - - function it_is_initializable() - { - $this->shouldHaveType('Http\Client\Exception\BatchException'); - } - - function it_is_a_runtime_exception() - { - $this->shouldHaveType('RuntimeException'); - } - - function it_is_an_exception() - { - $this->shouldImplement('Http\Client\Exception'); - } - - function it_has_a_batch_result() - { - $this->getResult()->shouldHaveType('Http\Client\BatchResult'); - } -} diff --git a/src/BatchResult.php b/src/BatchResult.php deleted file mode 100644 index 472d21a..0000000 --- a/src/BatchResult.php +++ /dev/null @@ -1,103 +0,0 @@ - - */ -interface BatchResult -{ - /** - * Checks if there are any successful responses at all. - * - * @return boolean - */ - public function hasResponses(); - - /** - * Returns all successful responses. - * - * @return ResponseInterface[] - */ - public function getResponses(); - - /** - * Checks if there is a successful response for a request. - * - * @param RequestInterface $request - * - * @return boolean - */ - public function isSuccessful(RequestInterface $request); - - /** - * Returns the response for a successful request. - * - * @param RequestInterface $request - * - * @return ResponseInterface - * - * @throws \UnexpectedValueException If request was not part of the batch or failed. - */ - public function getResponseFor(RequestInterface $request); - - /** - * Adds a response in an immutable way. - * - * @param RequestInterface $request - * @param ResponseInterface $response - * - * @return BatchResult the new BatchResult with this request-response pair added to it. - */ - public function addResponse(RequestInterface $request, ResponseInterface $response); - - /** - * Checks if there are any unsuccessful requests at all. - * - * @return boolean - */ - public function hasExceptions(); - - /** - * Returns all exceptions for the unsuccessful requests. - * - * @return Exception[] - */ - public function getExceptions(); - - /** - * Checks if there is an exception for a request, meaning the request failed. - * - * @param RequestInterface $request - * - * @return boolean - */ - public function isFailed(RequestInterface $request); - - /** - * Returns the exception for a failed request. - * - * @param RequestInterface $request - * - * @return Exception - * - * @throws \UnexpectedValueException If request was not part of the batch or was successful. - */ - public function getExceptionFor(RequestInterface $request); - - /** - * Adds an exception in an immutable way. - * - * @param RequestInterface $request - * @param Exception $exception - * - * @return BatchResult the new BatchResult with this request-exception pair added to it. - */ - public function addException(RequestInterface $request, Exception $exception); -} diff --git a/src/Exception/BatchException.php b/src/Exception/BatchException.php deleted file mode 100644 index 065c7c9..0000000 --- a/src/Exception/BatchException.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ -final class BatchException extends TransferException implements Exception -{ - /** - * @var BatchResult - */ - private $result; - - /** - * @param BatchResult $result - */ - public function __construct(BatchResult $result) - { - $this->result = $result; - } - - /** - * Returns the BatchResult that contains all responses and exceptions - * - * @return BatchResult - */ - public function getResult() - { - return $this->result; - } -} diff --git a/src/HttpClient.php b/src/HttpClient.php index d5c2187..6e2d313 100644 --- a/src/HttpClient.php +++ b/src/HttpClient.php @@ -25,22 +25,4 @@ interface HttpClient * @throws Exception */ public function sendRequest(RequestInterface $request); - - /** - * Sends several PSR-7 requests. - * - * If the client is able to, these requests should be sent in parallel. Otherwise they will be sent sequentially. - * Either way, the caller may not rely on them being executed in any particular order. - * - * If one or more requests led to an exception, the BatchException is thrown. The BatchException gives access to the - * BatchResult that contains responses for successful calls and exceptions for unsuccessful calls. - * - * @param RequestInterface[] $requests - * - * @return BatchResult If all requests where successful. - * - * @throws Exception On general setup problems. - * @throws BatchException If one or more requests led to exceptions. - */ - public function sendRequests(array $requests); }