From 829864532b1596e1dd0741fbaa647ab25a3e17e0 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Tue, 20 Oct 2015 15:56:21 +0200 Subject: [PATCH] move HttpMethodsClient to implementation in utils, rename psr client to simply client --- src/HttpClient.php | 36 ++++++++++- src/HttpMethodsClient.php | 132 -------------------------------------- src/HttpPsrClient.php | 41 ------------ 3 files changed, 33 insertions(+), 176 deletions(-) delete mode 100644 src/HttpMethodsClient.php delete mode 100644 src/HttpPsrClient.php diff --git a/src/HttpClient.php b/src/HttpClient.php index b870451..c366087 100644 --- a/src/HttpClient.php +++ b/src/HttpClient.php @@ -2,12 +2,42 @@ namespace Http\Client; +use Http\Client\Exception\BatchException; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + /** - * Interface for both HTTP Client type + * Sends one or more PSR-7 Request and returns PSR-7 responses. * - * @author Márk Sági-Kazár mark.sagikazar@gmail.com> + * @author GeLo + * @author Márk Sági-Kazár + * @author David Buchmann */ -interface HttpClient extends HttpPsrClient, HttpMethodsClient +interface HttpClient { + /** + * Sends a PSR request + * + * @param RequestInterface $request + * + * @return ResponseInterface + * + * @throws Exception + */ + public function sendRequest(RequestInterface $request); + /** + * Sends PSR requests + * + * If one or more requests led to an exception, the BatchException is thrown. + * The BatchException also gives access to the BatchResult for the successful responses. + * + * @param RequestInterface[] $requests + * + * @return BatchResult If all requests where successful. + * + * @throws Exception + * @throws BatchException + */ + public function sendRequests(array $requests); } diff --git a/src/HttpMethodsClient.php b/src/HttpMethodsClient.php deleted file mode 100644 index 9aedb15..0000000 --- a/src/HttpMethodsClient.php +++ /dev/null @@ -1,132 +0,0 @@ - - */ -interface HttpMethodsClient -{ - /** - * Sends a GET request - * - * @param string|UriInterface $uri - * @param array $headers - * - * @throws Exception - * - * @return ResponseInterface - */ - public function get($uri, array $headers = []); - - /** - * Sends an HEAD request - * - * @param string|UriInterface $uri - * @param array $headers - * - * @throws Exception - * - * @return ResponseInterface - */ - public function head($uri, array $headers = []); - - /** - * Sends a TRACE request - * - * @param string|UriInterface $uri - * @param array $headers - * - * @throws Exception - * - * @return ResponseInterface - */ - public function trace($uri, array $headers = []); - - /** - * Sends a POST request - * - * @param string|UriInterface $uri - * @param array $headers - * @param string|StreamInterface|null $body - * - * @throws Exception - * - * @return ResponseInterface - */ - public function post($uri, array $headers = [], $body = null); - - /** - * Sends a PUT request - * - * @param string|UriInterface $uri - * @param array $headers - * @param string|StreamInterface|null $body - * - * @throws Exception - * - * @return ResponseInterface - */ - public function put($uri, array $headers = [], $body = null); - - /** - * Sends a PATCH request - * - * @param string|UriInterface $uri - * @param array $headers - * @param string|StreamInterface|null $body - * - * @throws Exception - * - * @return ResponseInterface - */ - public function patch($uri, array $headers = [], $body = null); - - /** - * Sends a DELETE request - * - * @param string|UriInterface $uri - * @param array $headers - * @param string|StreamInterface|null $body - * - * @throws Exception - * - * @return ResponseInterface - */ - public function delete($uri, array $headers = [], $body = null); - - /** - * Sends an OPTIONS request - * - * @param string|UriInterface $uri - * @param array $headers - * @param string|StreamInterface|null $body - * - * @throws Exception - * - * @return ResponseInterface - */ - public function options($uri, array $headers = [], $body = null); - - /** - * Sends a request - * - * @param string $method - * @param string|UriInterface $uri - * @param array $headers - * @param string|StreamInterface|null $body - * - * @throws Exception - * - * @return ResponseInterface - */ - public function send($method, $uri, array $headers = [], $body = null); -} diff --git a/src/HttpPsrClient.php b/src/HttpPsrClient.php deleted file mode 100644 index 0e90df4..0000000 --- a/src/HttpPsrClient.php +++ /dev/null @@ -1,41 +0,0 @@ - - */ -interface HttpPsrClient -{ - /** - * Sends a PSR request - * - * @param RequestInterface $request - * - * @return ResponseInterface - * - * @throws Exception - */ - public function sendRequest(RequestInterface $request); - - /** - * Sends PSR requests - * - * If one or more requests led to an exception, the BatchException is thrown. - * The BatchException also gives access to the BatchResult for the successful responses. - * - * @param RequestInterface[] $requests - * - * @return BatchResult If all requests where successful. - * - * @throws Exception - * @throws BatchException - */ - public function sendRequests(array $requests); -}