update lock clucknut
All checks were successful
All checks were successful
This commit is contained in:
4
vendor/omnipay/common/src/Common/AbstractGateway.php
vendored
Normal file → Executable file
4
vendor/omnipay/common/src/Common/AbstractGateway.php
vendored
Normal file → Executable file
@@ -5,8 +5,8 @@
|
||||
|
||||
namespace Omnipay\Common;
|
||||
|
||||
use Omnipay\Common\Http\Client;
|
||||
use Omnipay\Common\Http\ClientInterface;
|
||||
use Omnipay\Common\Http\PsrClient;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
use Symfony\Component\HttpFoundation\Request as HttpRequest;
|
||||
|
||||
@@ -329,7 +329,7 @@ protected function createRequest($class, array $parameters)
|
||||
*/
|
||||
protected function getDefaultHttpClient()
|
||||
{
|
||||
return new Client();
|
||||
return new PsrClient();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
109
vendor/omnipay/common/src/Common/Http/AbstractClient.php
vendored
Normal file
109
vendor/omnipay/common/src/Common/Http/AbstractClient.php
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace Omnipay\Common\Http;
|
||||
|
||||
use Http\Discovery\Psr17FactoryDiscovery;
|
||||
use Http\Discovery\Psr18ClientDiscovery;
|
||||
use Http\Message\RequestFactory;
|
||||
use Omnipay\Common\Http\Exception\NetworkException;
|
||||
use Omnipay\Common\Http\Exception\RequestException;
|
||||
use Psr\Http\Client\ClientInterface as HttpClientInterface;
|
||||
use Psr\Http\Client\NetworkExceptionInterface;
|
||||
use Psr\Http\Message\RequestFactoryInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\StreamFactoryInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
abstract class AbstractClient implements ClientInterface
|
||||
{
|
||||
/** @var HttpClientInterface */
|
||||
private $httpClient;
|
||||
|
||||
/** @var RequestFactoryInterface|RequestFactory */
|
||||
private $requestFactory;
|
||||
|
||||
/** @var StreamFactoryInterface|null */
|
||||
private $streamFactory;
|
||||
|
||||
public function __construct(
|
||||
$httpClient = null,
|
||||
null|RequestFactoryInterface|RequestFactory $requestFactory = null,
|
||||
?StreamFactoryInterface $streamFactory = null
|
||||
) {
|
||||
$this->httpClient = $httpClient ?: Psr18ClientDiscovery::find();
|
||||
$this->requestFactory = $requestFactory ?: Psr17FactoryDiscovery::findRequestFactory();
|
||||
$this->streamFactory = $streamFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function request(
|
||||
$method,
|
||||
$uri,
|
||||
array $headers = [],
|
||||
$body = null,
|
||||
$protocolVersion = '1.1'
|
||||
) {
|
||||
$request = $this->createRequest($method, $uri, $headers, $body, $protocolVersion);
|
||||
|
||||
return $this->sendRequest($request);
|
||||
}
|
||||
|
||||
protected function createRequest(
|
||||
$method,
|
||||
$uri,
|
||||
array $headers = [],
|
||||
$body = null,
|
||||
$protocolVersion = '1.1'
|
||||
): RequestInterface {
|
||||
if ($this->requestFactory instanceof RequestFactory) {
|
||||
return $this->requestFactory->createRequest($method, $uri, $headers, $body, $protocolVersion);
|
||||
}
|
||||
|
||||
$request = $this->requestFactory->createRequest($method, $uri)->withProtocolVersion($protocolVersion);
|
||||
|
||||
foreach ($headers as $name => $value) {
|
||||
$request = $request->withHeader($name, $value);
|
||||
}
|
||||
|
||||
if ($body !== '' && $body !== null) {
|
||||
if (is_resource($body)) {
|
||||
$stream = $this->getStreamFactory()->createStreamFromResource($body);
|
||||
} elseif ($body instanceof StreamInterface) {
|
||||
$stream = $body;
|
||||
} elseif (is_scalar($body) || (is_object($body) && method_exists($body, '__toString'))) {
|
||||
$stream = $this->getStreamFactory()->createStream((string)$body);
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid body type: ' . gettype($body));
|
||||
}
|
||||
$request = $request->withBody($stream);
|
||||
}
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RequestInterface $request
|
||||
* @return ResponseInterface
|
||||
* @throws NetworkException|RequestException
|
||||
*/
|
||||
private function sendRequest(RequestInterface $request)
|
||||
{
|
||||
try {
|
||||
return $this->httpClient->sendRequest($request);
|
||||
} catch (NetworkExceptionInterface $networkException) {
|
||||
throw new NetworkException($networkException->getMessage(), $request, $networkException);
|
||||
} catch (\Throwable $exception) {
|
||||
throw new RequestException($exception->getMessage(), $request, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
private function getStreamFactory(): StreamFactoryInterface
|
||||
{
|
||||
$this->streamFactory = $this->streamFactory ?: Psr17FactoryDiscovery::findStreamFactory();
|
||||
|
||||
return $this->streamFactory;
|
||||
}
|
||||
}
|
||||
66
vendor/omnipay/common/src/Common/Http/Client.php
vendored
66
vendor/omnipay/common/src/Common/Http/Client.php
vendored
@@ -2,71 +2,15 @@
|
||||
|
||||
namespace Omnipay\Common\Http;
|
||||
|
||||
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\ResponseInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
class Client implements ClientInterface
|
||||
/**
|
||||
* @deprecated use Psr18Client instead
|
||||
*/
|
||||
class Client extends AbstractClient
|
||||
{
|
||||
/**
|
||||
* The Http Client which implements `public function sendRequest(RequestInterface $request)`
|
||||
* Note: Will be changed to PSR-18 when released
|
||||
*
|
||||
* @var HttpClient
|
||||
*/
|
||||
private $httpClient;
|
||||
|
||||
/**
|
||||
* @var RequestFactory
|
||||
*/
|
||||
private $requestFactory;
|
||||
|
||||
public function __construct($httpClient = null, ?RequestFactory $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
|
||||
* @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);
|
||||
|
||||
return $this->sendRequest($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RequestInterface $request
|
||||
* @return ResponseInterface
|
||||
* @throws \Http\Client\Exception
|
||||
*/
|
||||
private function sendRequest(RequestInterface $request)
|
||||
{
|
||||
try {
|
||||
return $this->httpClient->sendRequest($request);
|
||||
} catch (\Http\Client\Exception\NetworkException $networkException) {
|
||||
throw new NetworkException($networkException->getMessage(), $request, $networkException);
|
||||
} catch (\Exception $exception) {
|
||||
throw new RequestException($exception->getMessage(), $request, $exception);
|
||||
}
|
||||
parent::__construct($httpClient, $requestFactory);
|
||||
}
|
||||
}
|
||||
|
||||
18
vendor/omnipay/common/src/Common/Http/PsrClient.php
vendored
Normal file
18
vendor/omnipay/common/src/Common/Http/PsrClient.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Omnipay\Common\Http;
|
||||
|
||||
use Psr\Http\Client\ClientInterface as HttpClientInterface;
|
||||
use Psr\Http\Message\RequestFactoryInterface;
|
||||
use Psr\Http\Message\StreamFactoryInterface;
|
||||
|
||||
class PsrClient extends AbstractClient
|
||||
{
|
||||
public function __construct(
|
||||
?HttpClientInterface $httpClient = null,
|
||||
?RequestFactoryInterface $requestFactory = null,
|
||||
?StreamFactoryInterface $streamFactory = null
|
||||
) {
|
||||
parent::__construct($httpClient, $requestFactory, $streamFactory);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@
|
||||
use Omnipay\Common\Exception\InvalidRequestException;
|
||||
use Omnipay\Common\Exception\RuntimeException;
|
||||
use Omnipay\Common\Helper;
|
||||
use Omnipay\Common\Http\Client;
|
||||
use Omnipay\Common\Http\ClientInterface;
|
||||
use Omnipay\Common\ItemBag;
|
||||
use Omnipay\Common\ParametersTrait;
|
||||
|
||||
0
vendor/omnipay/common/src/Common/Message/NotificationInterface.php
vendored
Normal file → Executable file
0
vendor/omnipay/common/src/Common/Message/NotificationInterface.php
vendored
Normal file → Executable file
Reference in New Issue
Block a user