abstract class Connector

Traits

Properties

protected null|Response> $response

The default response class.

from  HasCustomResponses
static protected array $macros

The registered string macros.

from  Macroable

Methods

mixed
createDtoFromResponse(Response $response)

Create a data object from the response.

void
boot(PendingRequest $pendingRequest)

Configure a pending request for this resource.

from  Bootable
mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

RequestInterface
handlePsrRequest(RequestInterface $request, PendingRequest $pendingRequest)

Handle the final PSR request before it is sent.

string|null
resolveResponseClass(Response $response)

Resolve the custom response class.

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

static Makeable
make(mixed ...$arguments)

Create a new instance with the given arguments.

from  Makeable
bool|null
hasRequestFailed(Response $response)

Determine if the request failed.

getRequestException(Response $response)

Resolve the request exception.

bool
shouldThrowRequestException(Response $response)

Determine if the response should throw a request exception.

string
resolveBaseUrl()

Resolve the integration base URL.

send(Request $request, MockClient|null $mockClient = null)

Send a request through this connector.

createPendingRequest(Request $request)

Prepare a request for sending through this connector.

void
clearCache(Request $counterpart)

Clear the cached response for a request without sending it.

pool(iterable|callable $requests = [], int $concurrency = 5, callable|null $responseHandler = null, callable|null $exceptionHandler = null)

Create a bounded request pool.

string|null
resolveHttpConnection()

Resolve the HTTP connection used by this connector.

bool
allowsBaseUrlOverride()

Resolve whether requests may replace this connector's base URL.

array
headers()

Get the default headers.

array
queryParameters()

Get the default query parameters.

array
options()

Get the default request options.

authenticator()

Get the default authenticator.

int|null
delayMilliseconds()

Get the default request delay in milliseconds.

retryPolicy()

Get the default retry policy for requests without their own.

copyDefaultBodyRepository()

Copy the default body repository for a pending request.

array
defaultHeaders()

Resolve the default headers.

array
defaultQuery()

Resolve the default query parameters.

array
defaultOptions()

Resolve the default request options.

defaultAuth()

Resolve the default authenticator.

int|null
defaultDelay()

Resolve the default request delay in milliseconds.

defaultRetryPolicy()

Resolve the default retry policy.

defaultBodyRepository()

Resolve the default body repository.

string|null
resolveCacheKey(PendingRequest $pendingRequest)

Resolve the custom cache key.

array
resolveCacheableMethods()

Resolve the cacheable HTTP methods.

bool
usesRateLimits(PendingRequest $pendingRequest)

Determine if the connector's rate limits apply to an operation.

array
resolveRateLimitPolicies(PendingRequest $pendingRequest)

Resolve the connector's admission policies.

UnitEnum|string|null
resolveRateLimitStoreName()

Resolve the connector's rate limiter store.

string
rateLimiterName()

Resolve the identity whose limits and cooldowns the connector uses.

bool
shouldWaitForRateLimits(AdmissionPolicy|Cooldown $policy, Decision $result)

Determine if a denied connector rate limit should be awaited.

string
resolveRateLimitCooldownKeyFor(PendingRequest $pendingRequest)

Resolve the connector's stable cooldown key.

int|null
resolveRateLimitCooldownFor(Response $response)

Resolve the connector cooldown imposed by a response.

string|null
cacheKey(PendingRequest $pendingRequest)

Define a custom cache key.

array
cacheableMethods()

Define the cacheable HTTP methods.

static void
flushState()

Flush all static state.

Details

mixed createDtoFromResponse(Response $response)

Create a data object from the response.

Parameters

Response $response

Return Value

mixed

in Bootable at line 14
void boot(PendingRequest $pendingRequest)

Configure a pending request for this resource.

Parameters

PendingRequest $pendingRequest

Return Value

void

in Conditionable at line 23
mixed when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in Conditionable at line 56
mixed unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in HandlesPsrRequest at line 15
RequestInterface handlePsrRequest(RequestInterface $request, PendingRequest $pendingRequest)

Handle the final PSR request before it is sent.

Parameters

RequestInterface $request
PendingRequest $pendingRequest

Return Value

RequestInterface

in HasCustomResponses at line 23
string|null resolveResponseClass(Response $response)

Resolve the custom response class.

Parameters

Response $response

Return Value

string|null

in Macroable at line 30
static void macro(string $name, callable|object $macro)

Register a custom macro.

Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 44
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 61
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 72
static void flushMacros()

Flush the existing macros.

Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 83
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 108
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Makeable at line 12
static Makeable make(mixed ...$arguments)

Create a new instance with the given arguments.

Parameters

mixed ...$arguments

Return Value

Makeable

in ManagesExceptions at line 15
bool|null hasRequestFailed(Response $response)

Determine if the request failed.

Parameters

Response $response

Return Value

bool|null

in ManagesExceptions at line 23
RequestException|null getRequestException(Response $response)

Resolve the request exception.

Parameters

Response $response

Return Value

RequestException|null

in ManagesExceptions at line 31
bool shouldThrowRequestException(Response $response)

Determine if the response should throw a request exception.

Parameters

Response $response

Return Value

bool

at line 45
abstract string resolveBaseUrl()

Resolve the integration base URL.

Return Value

string

at line 54
Response send(Request $request, MockClient|null $mockClient = null)

Send a request through this connector.

Parameters

Request $request
MockClient|null $mockClient

Return Value

Response

at line 74
PendingRequest createPendingRequest(Request $request)

Prepare a request for sending through this connector.

The pending request has run its hooks and request middleware but has not been finalized or sent.

Parameters

Request $request

Return Value

PendingRequest

at line 85
void clearCache(Request $counterpart)

Clear the cached response for a request without sending it.

Parameters

Request $counterpart

Return Value

void

at line 100
Pool pool(iterable|callable $requests = [], int $concurrency = 5, callable|null $responseHandler = null, callable|null $exceptionHandler = null)

Create a bounded request pool.

Parameters

iterable|callable $requests
int $concurrency
callable|null $responseHandler
callable|null $exceptionHandler

Return Value

Pool

at line 112
string|null resolveHttpConnection()

Resolve the HTTP connection used by this connector.

Return Value

string|null

at line 123
bool allowsBaseUrlOverride()

Resolve whether requests may replace this connector's base URL.

Return Value

bool

at line 133
final array headers()

Get the default headers.

Return Value

array

at line 143
final array queryParameters()

Get the default query parameters.

Return Value

array

at line 153
final array options()

Get the default request options.

Return Value

array

at line 161
final Authenticator|null authenticator()

Get the default authenticator.

Return Value

Authenticator|null

at line 169
final int|null delayMilliseconds()

Get the default request delay in milliseconds.

Return Value

int|null

at line 177
final RetryPolicy|null retryPolicy()

Get the default retry policy for requests without their own.

Return Value

RetryPolicy|null

at line 187
final BodyRepository|null copyDefaultBodyRepository()

internal  
 

Copy the default body repository for a pending request.

Return Value

BodyRepository|null

at line 199
protected array defaultHeaders()

Resolve the default headers.

Return Value

array

at line 209
protected array defaultQuery()

Resolve the default query parameters.

Return Value

array

at line 219
protected array defaultOptions()

Resolve the default request options.

Return Value

array

at line 227
protected Authenticator|null defaultAuth()

Resolve the default authenticator.

Return Value

Authenticator|null

at line 235
protected int|null defaultDelay()

Resolve the default request delay in milliseconds.

Return Value

int|null

at line 243
protected RetryPolicy|null defaultRetryPolicy()

Resolve the default retry policy.

Return Value

RetryPolicy|null

at line 251
protected BodyRepository|null defaultBodyRepository()

Resolve the default body repository.

Return Value

BodyRepository|null

at line 261
final string|null resolveCacheKey(PendingRequest $pendingRequest)

internal  
 

Resolve the custom cache key.

Parameters

PendingRequest $pendingRequest

Return Value

string|null

at line 272
final array resolveCacheableMethods()

internal  
 

Resolve the cacheable HTTP methods.

Return Value

array

at line 282
bool usesRateLimits(PendingRequest $pendingRequest)

internal  
 

Determine if the connector's rate limits apply to an operation.

Parameters

PendingRequest $pendingRequest

Return Value

bool

at line 293
array resolveRateLimitPolicies(PendingRequest $pendingRequest)

internal  
 

Resolve the connector's admission policies.

Parameters

PendingRequest $pendingRequest

Return Value

array

at line 303
UnitEnum|string|null resolveRateLimitStoreName()

internal  
 

Resolve the connector's rate limiter store.

Return Value

UnitEnum|string|null

at line 313
string rateLimiterName()

internal  
 

Resolve the identity whose limits and cooldowns the connector uses.

Return Value

string

at line 323
bool shouldWaitForRateLimits(AdmissionPolicy|Cooldown $policy, Decision $result)

internal  
 

Determine if a denied connector rate limit should be awaited.

Parameters

AdmissionPolicy|Cooldown $policy
Decision $result

Return Value

bool

at line 333
string resolveRateLimitCooldownKeyFor(PendingRequest $pendingRequest)

internal  
 

Resolve the connector's stable cooldown key.

Parameters

PendingRequest $pendingRequest

Return Value

string

at line 343
int|null resolveRateLimitCooldownFor(Response $response)

internal  
 

Resolve the connector cooldown imposed by a response.

Parameters

Response $response

Return Value

int|null

at line 351
protected string|null cacheKey(PendingRequest $pendingRequest)

Define a custom cache key.

Parameters

PendingRequest $pendingRequest

Return Value

string|null

at line 361
protected array cacheableMethods()

Define the cacheable HTTP methods.

Return Value

array

at line 369
static void flushState()

Flush all static state.

Return Value

void