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": { 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..0447f9a 100644 --- a/src/HttpAdapter.php +++ b/src/HttpAdapter.php @@ -11,142 +11,44 @@ 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 + * @param array $options * * @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, array $options = []); /** - * Sends a TRACE request - * - * @param string|UriInterface $uri - * @param string[] $headers + * Sends PSR requests * - * @throws \InvalidArgumentException - * @throws Exception\HttpAdapterException + * @param RequestInterface[] $requests + * @param array $options * - * @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, array $options = []); /** - * 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(); -}