Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738<?php
declare(strict_types=1);
namespace Wotnak\Atproto\Tests\Support;
use Psr\Http\Client\ClientInterface;use Psr\Http\Message\RequestInterface;use Psr\Http\Message\ResponseInterface;
final class OAuthTestHttpClient implements ClientInterface {
public ?RequestInterface $lastRequest = NULL;
public int $requestCount = 0;
/** * @param list<ResponseInterface|\Throwable> $responses */ public function __construct( private array $responses, ) {}
public function sendRequest(RequestInterface $request): ResponseInterface { $this->lastRequest = $request; $this->requestCount++; if ($this->responses === []) { throw new \RuntimeException('No test response queued.'); } $response = \array_shift($this->responses); if ($response instanceof \Throwable) { throw $response; } return $response; }
}