diff --git a/composer.json b/composer.json index be27a33e..4d3e87af 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,7 @@ "php": "^7.2|^8", "php-http/client-implementation": "^1", "php-http/message": "^1.5", - "php-http/message-factory": "^1.1", + "psr/http-factory": "^1.0.2", "php-http/discovery": "^1.14", "symfony/http-foundation": "^2.1|^3|^4|^5|^6|^7", "moneyphp/money": "^3.1|^4.0.3" diff --git a/src/Common/Http/Client.php b/src/Common/Http/Client.php index abd4a53d..590995ea 100644 --- a/src/Common/Http/Client.php +++ b/src/Common/Http/Client.php @@ -6,10 +6,10 @@ use Http\Client\HttpClient; use Http\Discovery\HttpClientDiscovery; use Http\Discovery\MessageFactoryDiscovery; -use Http\Message\RequestFactory; use Omnipay\Common\Http\Exception\NetworkException; use Omnipay\Common\Http\Exception\RequestException; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UriInterface; @@ -25,33 +25,25 @@ class Client implements ClientInterface private $httpClient; /** - * @var RequestFactory + * @var RequestFactoryInterface */ private $requestFactory; - public function __construct($httpClient = null, RequestFactory $requestFactory = null) + public function __construct($httpClient = null, RequestFactoryInterface $requestFactory = null) { $this->httpClient = $httpClient ?: HttpClientDiscovery::find(); $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find(); } /** - * @param $method - * @param $uri - * @param array $headers - * @param string|array|resource|StreamInterface|null $body - * @param string $protocolVersion + * @param string $method + * @param string|UriInterface $uri * @return ResponseInterface * @throws \Http\Client\Exception */ public function request( - $method, - $uri, - array $headers = [], - $body = null, - $protocolVersion = '1.1' - ) { - $request = $this->requestFactory->createRequest($method, $uri, $headers, $body, $protocolVersion); + $method, $uri) { + $request = $this->requestFactory->createRequest($method, $uri); return $this->sendRequest($request); } diff --git a/src/Common/Http/ClientInterface.php b/src/Common/Http/ClientInterface.php index 73593957..3f5ae9db 100644 --- a/src/Common/Http/ClientInterface.php +++ b/src/Common/Http/ClientInterface.php @@ -15,9 +15,6 @@ interface ClientInterface * * @param string $method * @param string|UriInterface $uri - * @param array $headers - * @param resource|string|StreamInterface|null $body - * @param string $protocolVersion * * @throws RequestException when the HTTP client is passed a request that is invalid and cannot be sent. * @throws NetworkException if there is an error with the network or the remote server cannot be reached. @@ -26,9 +23,6 @@ interface ClientInterface */ public function request( $method, - $uri, - array $headers = [], - $body = null, - $protocolVersion = '1.1' + $uri ); } diff --git a/tests/Common/Http/ClientTest.php b/tests/Common/Http/ClientTest.php index b2534824..c1dbace0 100644 --- a/tests/Common/Http/ClientTest.php +++ b/tests/Common/Http/ClientTest.php @@ -7,7 +7,7 @@ use Mockery as m; use GuzzleHttp\Psr7\Request; use Http\Client\HttpClient; -use Http\Message\RequestFactory; +use Psr\Http\Message\RequestFactoryInterface as RequestFactory; use Omnipay\Common\Http\Exception\RequestException; use Omnipay\Tests\TestCase; @@ -26,9 +26,6 @@ public function testSend() $mockFactory->shouldReceive('createRequest')->withArgs([ 'GET', '/path', - [], - null, - '1.1', ])->andReturn($request); $mockClient->shouldReceive('sendRequest') @@ -52,9 +49,6 @@ public function testSendException() $mockFactory->shouldReceive('createRequest')->withArgs([ 'GET', '/path', - [], - null, - '1.1', ])->andReturn($request); $mockClient->shouldReceive('sendRequest') @@ -79,9 +73,6 @@ public function testSendNetworkException() $mockFactory->shouldReceive('createRequest')->withArgs([ 'GET', '/path', - [], - null, - '1.1', ])->andReturn($request); $mockClient->shouldReceive('sendRequest') @@ -106,9 +97,6 @@ public function testSendExceptionGetRequest() $mockFactory->shouldReceive('createRequest')->withArgs([ 'GET', '/path', - [], - null, - '1.1', ])->andReturn($request); $exception = new \Exception('Something went wrong');