SaloonManager
class SaloonManager
Properties
| protected MiddlewarePipeline | $middleware | The middleware applied to every Saloon request. |
|
| protected null|PendingRequest): ?string | $cacheScopeResolver | The cache scope resolver. |
|
| protected string|null | $fixturePath | The tests-only fixture path override. |
|
| protected bool|null | $throwOnMissingFixtures | The tests-only missing fixture behavior override. |
|
| protected MockClient|null | $mockClient | The tests-only global mock client. |
Methods
Create the Saloon manager.
Send a request through a connector.
Get the rate limiter manager.
Get the global middleware pipeline.
Get the global mock client.
Clear the global mock client.
Assert that a matching request was sent.
Assert that no matching request was sent.
Assert that requests were sent in order.
Assert that nothing was sent.
Assert the number of recorded requests.
Set the fixture storage path.
Get the fixture storage path.
Configure missing fixture behavior.
Determine if missing fixtures should throw.
Sleep for a checked number of milliseconds.
Resolve the cache store and bounded key for an operation.
Enforce connector and request rate limits before transport.
Enforce one rate-limited resource.
Record connector and request cooldowns from a transport response.
Record one resource's response-derived cooldown.
Wait for a denied policy or throw its result.
Details
at line 73
__construct(Sender $sender, Factory $cache, RateLimiter $rateLimiter, Repository $config, Dispatcher $events)
Create the Saloon manager.
at line 90
Response
send(Connector $connector, Request $request, MockClient|null $mockClient = null)
Send a request through a connector.
at line 255
Sender
sender()
Get the Saloon sender.
at line 263
Factory
cache()
Get the cache factory.
at line 271
RateLimiter
rateLimiter()
Get the rate limiter manager.
at line 282
MiddlewarePipeline
middleware()
Get the global middleware pipeline.
Boot-only. Middleware added to this pipeline persists on the manager for the worker lifetime and affects every subsequent Saloon request.
at line 295
MockClient
fake(array|MockClient $responses = [])
Replace the global mock client.
Tests only. The client persists on the manager until the test
application is destroyed or clearFake() is called.
at line 305
MockClient|null
mockClient()
Get the global mock client.
at line 318
SaloonManager
clearFake()
Clear the global mock client.
Tests only. This immediately removes the recorder for every subsequent Saloon request in the worker.
at line 328
void
assertSent(string|callable $value)
Assert that a matching request was sent.
at line 336
void
assertNotSent(string|callable $value)
Assert that no matching request was sent.
at line 346
void
assertSentInOrder(array $callbacks)
Assert that requests were sent in order.
at line 354
void
assertNothingSent()
Assert that nothing was sent.
at line 364
void
assertSentCount(int $count, string|null $requestClass = null)
Assert the number of recorded requests.
at line 377
SaloonManager
resolveCacheScopeUsing(Closure|null $resolver)
Register the cache scope resolver.
Boot-only. The callback persists on the manager for the worker lifetime and affects every subsequently cached Saloon request.
at line 387
string|null
resolveCacheScope(PendingRequest $pendingRequest)
Resolve the cache scope for the request.
at line 400
SaloonManager
fixturePath(string $path)
Set the fixture storage path.
Tests only. The override persists on the manager until the test application is destroyed.
at line 410
string
getFixturePath()
Get the fixture storage path.
at line 425
SaloonManager
throwOnMissingFixtures(bool $throw = true)
Configure missing fixture behavior.
Tests only. The override persists on the manager until the test application is destroyed.
at line 435
bool
throwsOnMissingFixtures()
Determine if missing fixtures should throw.
at line 444
protected void
sleepMilliseconds(int $milliseconds)
Sleep for a checked number of milliseconds.
at line 461
protected array
resolveCache(PendingRequest $pendingRequest, array $transport)
Resolve the cache store and bounded key for an operation.
at line 484
protected void
enforceRateLimits(PendingRequest $pendingRequest)
Enforce connector and request rate limits before transport.
at line 493
protected void
enforceRateLimitsFor(PendingRequest $pendingRequest, Connector|Request $resource)
Enforce one rate-limited resource.
at line 543
protected void
recordRateLimitCooldowns(PendingRequest $pendingRequest, Response $response)
Record connector and request cooldowns from a transport response.
at line 552
protected void
recordRateLimitCooldownFor(PendingRequest $pendingRequest, Response $response, Connector|Request $resource)
Record one resource's response-derived cooldown.
at line 572
protected Limiter
rateLimiterFor(Connector|Request $resource)
Resolve the framework limiter selected by a resource.
at line 585
protected void
waitForRateLimit(Connector|Request $resource, AdmissionPolicy|Cooldown $policy, Decision $result)
Wait for a denied policy or throw its result.