From f7827404aacf544ddc9e4b893f8b869192a0a6f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1gi-Kaz=C3=A1r=20M=C3=A1rk?= Date: Fri, 29 May 2015 15:17:39 +0200 Subject: [PATCH 1/4] Removes client related interfaces --- src/Configurable.php | 35 ------- src/ConfigurableHttpAdapter.php | 163 -------------------------------- src/HasConfiguration.php | 54 ----------- src/HttpAdapter.php | 126 +++--------------------- src/Message/Configurable.php | 41 -------- src/PsrHttpAdapter.php | 52 ---------- 6 files changed, 13 insertions(+), 458 deletions(-) delete mode 100644 src/Configurable.php delete mode 100644 src/ConfigurableHttpAdapter.php delete mode 100644 src/HasConfiguration.php delete mode 100644 src/Message/Configurable.php delete mode 100644 src/PsrHttpAdapter.php diff --git a/src/Configurable.php b/src/Configurable.php deleted file mode 100644 index ea6f4fc..0000000 --- a/src/Configurable.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Http\Adapter; - -/** - * Allows to modify configuration - * - * @author Márk Sági-Kazár mark.sagikazar@gmail.com> - */ -interface Configurable extends HasConfiguration -{ - /** - * Sets an option - * - * @param string $name - * @param mixed $option - */ - public function setOption($name, $option); - - /** - * Sets all options - * - * @param array $options - */ - public function setOptions(array $options); -} diff --git a/src/ConfigurableHttpAdapter.php b/src/ConfigurableHttpAdapter.php deleted file mode 100644 index 1203cf5..0000000 --- a/src/ConfigurableHttpAdapter.php +++ /dev/null @@ -1,163 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Http\Adapter; - -use Psr\Http\Message\StreamInterface; -use Psr\Http\Message\UriInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Allows request level configurations - * - * @author Márk Sági-Kazár mark.sagikazar@gmail.com> - */ -interface ConfigurableHttpAdapter extends HttpAdapter -{ - /** - * Sends a GET request - * - * @param string|UriInterface $uri - * @param string[] $headers - * @param array $options - * - * @throws \InvalidArgumentException - * @throws HttpAdapterException - * - * @return ResponseInterface - */ - public function get($uri, array $headers = [], array $options = []); - - /** - * Sends an HEAD request - * - * @param string|UriInterface $uri - * @param string[] $headers - * @param array $options - * - * @throws \InvalidArgumentException - * @throws HttpAdapterException - * - * @return ResponseInterface - */ - public function head($uri, array $headers = [], array $options = []); - - /** - * Sends a TRACE request - * - * @param string|UriInterface $uri - * @param string[] $headers - * @param array $options - * - * @throws \InvalidArgumentException - * @throws HttpAdapterException - * - * @return ResponseInterface - */ - public function trace($uri, array $headers = [], array $options = []); - - /** - * Sends a POST request - * - * @param string|UriInterface $uri - * @param string[] $headers - * @param array|string|StreamInterface $data - * @param array $files - * @param array $options - * - * @throws \InvalidArgumentException - * @throws HttpAdapterException - * - * @return ResponseInterface - */ - public function post($uri, array $headers = [], $data = [], array $files = [], array $options = []); - - /** - * Sends a PUT request - * - * @param string|UriInterface $uri - * @param string[] $headers - * @param array|string|StreamInterface $data - * @param array $files - * @param array $options - * - * @throws \InvalidArgumentException - * @throws HttpAdapterException - * - * @return ResponseInterface - */ - public function put($uri, array $headers = [], $data = [], array $files = [], array $options = []); - - /** - * Sends a PATCH request - * - * @param string|UriInterface $uri - * @param string[] $headers - * @param array|string|StreamInterface $data - * @param array $files - * @param array $options - * - * @throws \InvalidArgumentException - * @throws HttpAdapterException - * - * @return ResponseInterface - */ - public function patch($uri, array $headers = [], $data = [], array $files = [], array $options = []); - - /** - * Sends a DELETE request - * - * @param string|UriInterface $uri - * @param string[] $headers - * @param array|string|StreamInterface $data - * @param array $files - * @param array $options - * - * @throws \InvalidArgumentException - * @throws HttpAdapterException - * - * @return ResponseInterface - */ - public function delete($uri, array $headers = [], $data = [], array $files = [], array $options = []); - - /** - * Sends an OPTIONS request - * - * @param string|UriInterface $uri - * @param string[] $headers - * @param array|string|StreamInterface $data - * @param array $files - * @param array $options - * - * @throws \InvalidArgumentException - * @throws HttpAdapterException - * - * @return ResponseInterface - */ - public function options($uri, array $headers = [], $data = [], array $files = [], array $options = []); - - /** - * Sends a request - * - * @param string $method - * @param string|UriInterface $uri - * @param string[] $headers - * @param array|string|StreamInterface $data - * @param array $files - * @param array $options - * - * @throws \InvalidArgumentException - * @throws HttpAdapterException - * - * @return ResponseInterface - */ - public function send($method, $uri, array $headers = [], $data = [], array $files = [], array $options = []); -} diff --git a/src/HasConfiguration.php b/src/HasConfiguration.php deleted file mode 100644 index 0899c9b..0000000 --- a/src/HasConfiguration.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Http\Adapter; - -/** - * Provides a configuration reading interface - * - * This interface does not allow modifying options - * - * @author Márk Sági-Kazár mark.sagikazar@gmail.com> - */ -interface HasConfiguration -{ - /** - * Returns an option by name - * - * @param string $name - * - * @return mixed - */ - public function getOption($name); - - /** - * Returns all options - * - * @return array - */ - public function getOptions(); - - /** - * Checks if an option exists - * - * @param string $name - * - * @return boolean - */ - public function hasOption($name); - - /** - * Checks if any option exists - * - * @return boolean - */ - public function hasOptions(); -} diff --git a/src/HttpAdapter.php b/src/HttpAdapter.php index e84dae0..c54da24 100644 --- a/src/HttpAdapter.php +++ b/src/HttpAdapter.php @@ -11,142 +11,42 @@ namespace Http\Adapter; -use Psr\Http\Message\StreamInterface; -use Psr\Http\Message\UriInterface; +use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; /** * @author GeLo */ -interface HttpAdapter extends PsrHttpAdapter +interface HttpAdapter { /** - * Sends a GET request + * Sends a PSR request * - * @param string|UriInterface $uri - * @param string[] $headers - * - * @throws \InvalidArgumentException - * @throws Exception\HttpAdapterException + * @param RequestInterface $request * * @return ResponseInterface - */ - public function get($uri, array $headers = []); - - /** - * Sends an HEAD request - * - * @param string|UriInterface $uri - * @param string[] $headers * * @throws \InvalidArgumentException * @throws Exception\HttpAdapterException - * - * @return ResponseInterface */ - public function head($uri, array $headers = []); + public function sendRequest(RequestInterface $request); /** - * Sends a TRACE request - * - * @param string|UriInterface $uri - * @param string[] $headers + * Sends PSR requests * - * @throws \InvalidArgumentException - * @throws Exception\HttpAdapterException + * @param RequestInterface[] $requests * - * @return ResponseInterface - */ - public function trace($uri, array $headers = []); - - /** - * Sends a POST request - * - * @param string|UriInterface $uri - * @param string[] $headers - * @param array|string|StreamInterface $data - * @param array $files + * @return ResponseInterface[] * * @throws \InvalidArgumentException - * @throws Exception\HttpAdapterException - * - * @return ResponseInterface + * @throws Exception\MultiHttpAdapterException */ - public function post($uri, array $headers = [], $data = [], array $files = []); + public function sendRequests(array $requests); /** - * Sends a PUT request - * - * @param string|UriInterface $uri - * @param string[] $headers - * @param array|string|StreamInterface $data - * @param array $files - * - * @throws \InvalidArgumentException - * @throws Exception\HttpAdapterException + * Returns the name * - * @return ResponseInterface - */ - public function put($uri, array $headers = [], $data = [], array $files = []); - - /** - * Sends a PATCH request - * - * @param string|UriInterface $uri - * @param string[] $headers - * @param array|string|StreamInterface $data - * @param array $files - * - * @throws \InvalidArgumentException - * @throws Exception\HttpAdapterException - * - * @return ResponseInterface - */ - public function patch($uri, array $headers = [], $data = [], array $files = []); - - /** - * Sends a DELETE request - * - * @param string|UriInterface $uri - * @param string[] $headers - * @param array|string|StreamInterface $data - * @param array $files - * - * @throws \InvalidArgumentException - * @throws Exception\HttpAdapterException - * - * @return ResponseInterface - */ - public function delete($uri, array $headers = [], $data = [], array $files = []); - - /** - * Sends an OPTIONS request - * - * @param string|UriInterface $uri - * @param string[] $headers - * @param array|string|StreamInterface $data - * @param array $files - * - * @throws \InvalidArgumentException - * @throws Exception\HttpAdapterException - * - * @return ResponseInterface - */ - public function options($uri, array $headers = [], $data = [], array $files = []); - - /** - * Sends a request - * - * @param string $method - * @param string|UriInterface $uri - * @param string[] $headers - * @param array|string|StreamInterface $data - * @param array $files - * - * @throws \InvalidArgumentException - * @throws Exception\HttpAdapterException - * - * @return ResponseInterface + * @return string */ - public function send($method, $uri, array $headers = [], $data = [], array $files = []); + public function getName(); } diff --git a/src/Message/Configurable.php b/src/Message/Configurable.php deleted file mode 100644 index b994e48..0000000 --- a/src/Message/Configurable.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Http\Adapter\Message; - -use Http\Adapter\HasConfiguration; - -/** - * Allows to modify configuration in a message an immutable way - * - * @author Márk Sági-Kazár mark.sagikazar@gmail.com> - */ -interface Configurable extends HasConfiguration -{ - /** - * Sets an option - * - * @param string $name - * @param mixed $option - * - * @return self - */ - public function withOption($name, $option); - - /** - * Removes an option - * - * @param string $name - * - * @return self - */ - public function withoutOption($name); -} diff --git a/src/PsrHttpAdapter.php b/src/PsrHttpAdapter.php deleted file mode 100644 index 2428a47..0000000 --- a/src/PsrHttpAdapter.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Http\Adapter; - -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * @author GeLo - */ -interface PsrHttpAdapter -{ - /** - * Sends a PSR request - * - * @param RequestInterface $request - * - * @return ResponseInterface - * - * @throws \InvalidArgumentException - * @throws Exception\HttpAdapterException - */ - public function sendRequest(RequestInterface $request); - - /** - * Sends PSR requests - * - * @param RequestInterface[] $requests - * - * @return ResponseInterface[] - * - * @throws \InvalidArgumentException - * @throws Exception\MultiHttpAdapterException - */ - public function sendRequests(array $requests); - - /** - * Returns the name - * - * @return string - */ - public function getName(); -} From c22c46bc5819668cc02c0b1751f1c7f09b77428e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1gi-Kaz=C3=A1r=20M=C3=A1rk?= Date: Fri, 29 May 2015 15:37:31 +0200 Subject: [PATCH 2/4] Added myself as author --- composer.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/composer.json b/composer.json index 6e2a5ea..cc44f5d 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,10 @@ { "name": "Eric GELOEN", "email": "geloen.eric@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" } ], "require": { From a3566c4cbb214b4f0b302b7fcac61a98ff4b44e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1gi-Kaz=C3=A1r=20M=C3=A1rk?= Date: Sat, 30 May 2015 21:32:51 +0200 Subject: [PATCH 3/4] Adds configurable HTTP adapter interface --- src/ConfigurableHttpAdapter.php | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/ConfigurableHttpAdapter.php diff --git a/src/ConfigurableHttpAdapter.php b/src/ConfigurableHttpAdapter.php new file mode 100644 index 0000000..df547ab --- /dev/null +++ b/src/ConfigurableHttpAdapter.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Http\Adapter; + +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * @author GeLo + */ +interface ConfigurableHttpAdapter extends HttpAdapter +{ + /** + * Sends a PSR request + * + * @param RequestInterface $request + * @param array $options + * + * @return ResponseInterface + * + * @throws \InvalidArgumentException + * @throws Exception\HttpAdapterException + */ + public function sendRequest(RequestInterface $request, array $options = []); + + /** + * Sends PSR requests + * + * @param RequestInterface[] $requests + * @param array $options + * + * @return ResponseInterface[] + * + * @throws \InvalidArgumentException + * @throws Exception\MultiHttpAdapterException + */ + public function sendRequests(array $requests, array $options = []); +} From 342010438c4b148e98f6f18795055754ca47656e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1gi-Kaz=C3=A1r=20M=C3=A1rk?= Date: Sun, 31 May 2015 16:25:05 +0200 Subject: [PATCH 4/4] Merges configurable and non-configurable adapters --- src/ConfigurableHttpAdapter.php | 47 --------------------------------- src/HttpAdapter.php | 6 +++-- 2 files changed, 4 insertions(+), 49 deletions(-) delete mode 100644 src/ConfigurableHttpAdapter.php diff --git a/src/ConfigurableHttpAdapter.php b/src/ConfigurableHttpAdapter.php deleted file mode 100644 index df547ab..0000000 --- a/src/ConfigurableHttpAdapter.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Http\Adapter; - -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * @author GeLo - */ -interface ConfigurableHttpAdapter extends HttpAdapter -{ - /** - * Sends a PSR request - * - * @param RequestInterface $request - * @param array $options - * - * @return ResponseInterface - * - * @throws \InvalidArgumentException - * @throws Exception\HttpAdapterException - */ - public function sendRequest(RequestInterface $request, array $options = []); - - /** - * Sends PSR requests - * - * @param RequestInterface[] $requests - * @param array $options - * - * @return ResponseInterface[] - * - * @throws \InvalidArgumentException - * @throws Exception\MultiHttpAdapterException - */ - public function sendRequests(array $requests, array $options = []); -} diff --git a/src/HttpAdapter.php b/src/HttpAdapter.php index c54da24..0447f9a 100644 --- a/src/HttpAdapter.php +++ b/src/HttpAdapter.php @@ -23,25 +23,27 @@ interface HttpAdapter * Sends a PSR request * * @param RequestInterface $request + * @param array $options * * @return ResponseInterface * * @throws \InvalidArgumentException * @throws Exception\HttpAdapterException */ - public function sendRequest(RequestInterface $request); + public function sendRequest(RequestInterface $request, array $options = []); /** * Sends PSR requests * * @param RequestInterface[] $requests + * @param array $options * * @return ResponseInterface[] * * @throws \InvalidArgumentException * @throws Exception\MultiHttpAdapterException */ - public function sendRequests(array $requests); + public function sendRequests(array $requests, array $options = []); /** * Returns the name