forked from loafle/openapi-generator-original
* php-nextgen first commit * [php] Set minimal PHP version to ^8.0 (#14500) * Set minimal PHP version to ^8.0 * Fix php-nextgen config * Change stability to BETA * Add phplint package (#15054) * [php-nextgen] Rename folders to follow PDS skeleton (#15102) * Change lib -> src, test -> tests folder This will make build compliant to PHP-PDS skeleton. Ref: https://github.com/php-pds/skeleton * Refresh samples * Exclude composer.lock from codebase (#15105) Since client generator is library and not a project it makes sense to exclude composer.lock from codebase by default. Ref: http://getcomposer.org/doc/02-libraries.md#lock-file * Add @generated tag to DocBlocks (#15106) This tag in draft status right now(PSR-19), but I think we can leverage from it already. Ref: https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc-tags.md#55-generated * update samples, doc * update samples --------- Co-authored-by: Yuriy Belenko <yura-bely@mail.ru>
71 lines
1.8 KiB
PHP
71 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace OpenAPI\Client;
|
|
|
|
use GuzzleHttp\ClientInterface;
|
|
use GuzzleHttp\Exception\GuzzleException;
|
|
use GuzzleHttp\Promise\PromiseInterface;
|
|
use GuzzleHttp\Psr7\Response;
|
|
use Psr\Http\Message\RequestInterface;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
class FakeHttpClient implements ClientInterface
|
|
{
|
|
/** @var RequestInterface|null */
|
|
private $request;
|
|
/** @var ResponseInterface|null */
|
|
private $response;
|
|
|
|
/**
|
|
* @return null|RequestInterface
|
|
*/
|
|
public function getLastRequest()
|
|
{
|
|
return $this->request;
|
|
}
|
|
|
|
/**
|
|
* @param null|ResponseInterface $response
|
|
*/
|
|
public function setResponse(ResponseInterface $response = null)
|
|
{
|
|
$this->response = $response;
|
|
}
|
|
|
|
/**
|
|
* Send an HTTP request.
|
|
*
|
|
* @param RequestInterface $request Request to send
|
|
* @param array $options Request options to apply to the given
|
|
* request and to the transfer.
|
|
*
|
|
* @return ResponseInterface
|
|
* @throws GuzzleException
|
|
*/
|
|
public function send(RequestInterface $request, array $options = []): ResponseInterface
|
|
{
|
|
$this->request = $request;
|
|
return $this->response ?: new Response(200);
|
|
}
|
|
|
|
public function sendAsync(RequestInterface $request, array $options = []): PromiseInterface
|
|
{
|
|
throw new \RuntimeException('not implemented');
|
|
}
|
|
|
|
public function request($method, $uri, array $options = []): ResponseInterface
|
|
{
|
|
throw new \RuntimeException('not implemented');
|
|
}
|
|
|
|
public function requestAsync($method, $uri, array $options = []): PromiseInterface
|
|
{
|
|
throw new \RuntimeException('not implemented');
|
|
}
|
|
|
|
public function getConfig($option = null)
|
|
{
|
|
throw new \RuntimeException('not implemented');
|
|
}
|
|
}
|