Methods |
public
|
getUri(): UriInterface
Get the URI of the endpoint
Get the URI of the endpoint
Implemented by
|
#
|
public
|
withUri(UriInterface|Stringable|string|null $uri): static
Get an instance with the given endpoint URI
Get an instance with the given endpoint URI
An exception is thrown if the endpoint URI has a query or fragment.
Implemented by
|
#
|
public
|
withRequest(RequestInterface $request): static
Apply the URI and headers of the given request to a copy of the instance
Apply the URI and headers of the given request to a copy of the instance
Implemented by
|
#
|
public
|
getLastRequest(): ?RequestInterface
Get the last request sent to the endpoint or passed to middleware
Get the last request sent to the endpoint or passed to middleware
Implemented by
|
#
|
public
|
getLastResponse(): ?HttpResponseInterface
Get the last response received from the endpoint or returned by
middleware
Get the last response received from the endpoint or returned by
middleware
Implemented by
|
#
|
public
|
lastResponseIsJson(): bool
Check if the last response contains JSON-encoded data
Check if the last response contains JSON-encoded data
Throws
OutOfRangeException |
if no response has been received from the
endpoint or returned by middleware.
|
Implemented by
|
#
|
public
|
head(mixed[]|null $query = null): HttpHeadersInterface
Send a HEAD request to the endpoint
Send a HEAD request to the endpoint
Implemented by
|
#
|
public
|
get(mixed[]|null $query = null): mixed
Send a GET request to the endpoint and return the body of the response
Send a GET request to the endpoint and return the body of the response
Implemented by
|
#
|
public
|
post(mixed[]|object|null $data = null, mixed[]|null $query = null): mixed
Send a POST request to the endpoint and return the body of the response
Send a POST request to the endpoint and return the body of the response
Implemented by
|
#
|
public
|
put(mixed[]|object|null $data = null, mixed[]|null $query = null): mixed
Send a PUT request to the endpoint and return the body of the response
Send a PUT request to the endpoint and return the body of the response
Implemented by
|
#
|
public
|
patch(mixed[]|object|null $data = null, mixed[]|null $query = null): mixed
Send a PATCH request to the endpoint and return the body of the response
Send a PATCH request to the endpoint and return the body of the response
Implemented by
|
#
|
public
|
delete(mixed[]|object|null $data = null, mixed[]|null $query = null): mixed
Send a DELETE request to the endpoint and return the body of the response
Send a DELETE request to the endpoint and return the body of the response
Implemented by
|
#
|
public
|
getP(mixed[]|null $query = null): iterable<mixed>
Send a GET request to the endpoint and iterate over response pages
Send a GET request to the endpoint and iterate over response pages
Implemented by
|
#
|
public
|
postP(mixed[]|object|null $data = null, mixed[]|null $query = null): iterable<mixed>
Send a POST request to the endpoint and iterate over response pages
Send a POST request to the endpoint and iterate over response pages
Implemented by
|
#
|
public
|
putP(mixed[]|object|null $data = null, mixed[]|null $query = null): iterable<mixed>
Send a PUT request to the endpoint and iterate over response pages
Send a PUT request to the endpoint and iterate over response pages
Implemented by
|
#
|
public
|
patchP(mixed[]|object|null $data = null, mixed[]|null $query = null): iterable<mixed>
Send a PATCH request to the endpoint and iterate over response pages
Send a PATCH request to the endpoint and iterate over response pages
Implemented by
|
#
|
public
|
deleteP(mixed[]|object|null $data = null, mixed[]|null $query = null): iterable<mixed>
Send a DELETE request to the endpoint and iterate over response pages
Send a DELETE request to the endpoint and iterate over response pages
Implemented by
|
#
|
public
|
postR(string $data, string $mediaType, mixed[]|null $query = null): mixed
Send raw data to the endpoint in a POST request and return the body of
the response
Send raw data to the endpoint in a POST request and return the body of
the response
Implemented by
|
#
|
public
|
putR(string $data, string $mediaType, mixed[]|null $query = null): mixed
Send raw data to the endpoint in a PUT request and return the body of the
response
Send raw data to the endpoint in a PUT request and return the body of the
response
Implemented by
|
#
|
public
|
patchR(string $data, string $mediaType, mixed[]|null $query = null): mixed
Send raw data to the endpoint in a PATCH request and return the body of
the response
Send raw data to the endpoint in a PATCH request and return the body of
the response
Implemented by
|
#
|
public
|
deleteR(string $data, string $mediaType, mixed[]|null $query = null): mixed
Send raw data to the endpoint in a DELETE request and return the body of
the response
Send raw data to the endpoint in a DELETE request and return the body of
the response
Implemented by
|
#
|
public
|
flushCookies(): $this
Invalidate cached cookies
Invalidate cached cookies
Calling this method has no effect if the instance does not handle
cookies.
Implemented by
|
#
|
public
|
getHttpHeaders(): HttpHeadersInterface
Get request headers
|
#
|
public
|
getPublicHttpHeaders(): HttpHeadersInterface
Get request headers that are not considered sensitive
Get request headers that are not considered sensitive
Implemented by
|
#
|
public
|
getHeaders(): array<string, string[]>
Get an array that maps request header names to values
Get an array that maps request header names to values
|
#
|
public
|
hasHeader(string $name): bool
Check if a request header exists
Check if a request header exists
|
#
|
public
|
getHeader(string $name): string[]
Get the value of a request header as a list of values
Get the value of a request header as a list of values
|
#
|
public
|
getHeaderValues(string $name): string[]
Get the value of a request header as a list of values, splitting any
comma-separated values
Get the value of a request header as a list of values, splitting any
comma-separated values
|
#
|
public
|
getHeaderLine(string $name): string
Get the comma-separated values of a request header
Get the comma-separated values of a request header
|
#
|
public
|
getFirstHeaderLine(string $name): string
Get the first value of a request header after splitting any
comma-separated values
Get the first value of a request header after splitting any
comma-separated values
|
#
|
public
|
getLastHeaderLine(string $name): string
Get the last value of a request header after splitting any
comma-separated values
Get the last value of a request header after splitting any
comma-separated values
|
#
|
public
|
getOneHeaderLine(string $name, bool $orSame = false): string
Get the only value of a request header after splitting any
comma-separated values
Get the only value of a request header after splitting any
comma-separated values
An exception is thrown if the request header has more than one value.
|
#
|
public
|
withHeader(string $name, string[]|string $value): static
Get an instance with a value applied to a request header, replacing any
existing values
Get an instance with a value applied to a request header, replacing any
existing values
|
#
|
public
|
withAddedHeader(string $name, string[]|string $value): static
Get an instance with a value applied to a request header, preserving any
existing values
Get an instance with a value applied to a request header, preserving any
existing values
|
#
|
public
|
withoutHeader(string $name): static
Get an instance with a request header removed
Get an instance with a request header removed
|
#
|
public
|
hasAccessToken(): bool
Check if the instance has an access token
Check if the instance has an access token
Implemented by
|
#
|
public
|
withAccessToken(?AccessTokenInterface $token, string $headerName = HttpHeader::AUTHORIZATION): static
Get an instance that applies an access token to request headers
Get an instance that applies an access token to request headers
Implemented by
|
#
|
public
|
isSensitiveHeader(string $name): bool
Check if a header is considered sensitive
Check if a header is considered sensitive
Implemented by
|
#
|
public
|
withSensitiveHeader(string $name): static
Get an instance that treats a header as sensitive
Get an instance that treats a header as sensitive
Headers in {@see HttpHeaderGroup::SENSITIVE} are considered sensitive by
default.
Implemented by
|
#
|
public
|
withoutSensitiveHeader(string $name): static
Get an instance that does not treat the given header as sensitive
Get an instance that does not treat the given header as sensitive
Implemented by
|
#
|
public
|
getMediaType(): ?string
Get the media type applied to request headers
Get the media type applied to request headers
Implemented by
|
#
|
public
|
withMediaType(?string $type): static
Get an instance that applies the given media type to request headers
Get an instance that applies the given media type to request headers
If $type is null (the default), Content-Type headers are
automatically applied to requests as needed.
Implemented by
|
#
|
public
|
getUserAgent(): string
Get the current user agent string
Get the current user agent string
Implemented by
|
#
|
public
|
withUserAgent(?string $userAgent): static
Get an instance with the given user agent string
Get an instance with the given user agent string
If $userAgent is null , the default user agent string is restored.
Implemented by
|
#
|
public
|
expectsJson(): bool
Check if the instance explicitly accepts JSON-encoded responses and
assumes responses with no content type contain JSON
Check if the instance explicitly accepts JSON-encoded responses and
assumes responses with no content type contain JSON
Implemented by
|
#
|
public
|
withExpectJson(bool $expectJson = true): static
Get an instance that explicitly accepts JSON-encoded responses and
assumes responses with no content type contain JSON
Get an instance that explicitly accepts JSON-encoded responses and
assumes responses with no content type contain JSON
Implemented by
|
#
|
public
|
postsJson(): bool
Check if the instance uses JSON to encode POST/PUT/PATCH/DELETE data
Check if the instance uses JSON to encode POST/PUT/PATCH/DELETE data
Implemented by
|
#
|
public
|
withPostJson(bool $postJson = true): static
Get an instance that uses JSON to encode POST/PUT/PATCH/DELETE data
Get an instance that uses JSON to encode POST/PUT/PATCH/DELETE data
Implemented by
|
#
|
public
|
getDateFormatter(): ?DateFormatterInterface
Get the date formatter applied to the instance
Get the date formatter applied to the instance
Implemented by
|
#
|
public
|
withDateFormatter(?DateFormatterInterface $formatter): static
Get an instance that uses the given date formatter to format and parse
the endpoint's date and time values
Get an instance that uses the given date formatter to format and parse
the endpoint's date and time values
Implemented by
|
#
|
public
|
getFormDataFlags(): int-mask-of<FormDataFlag::*>
Get form data flags applied to the instance
Get form data flags applied to the instance
Implemented by
|
#
|
public
|
withFormDataFlags(int-mask-of<FormDataFlag::*> $flags): static
Get an instance with the given form data flags
Get an instance with the given form data flags
Form data flags are used to encode data for query strings and message
bodies.
{@see FormDataFlag::PRESERVE_NUMERIC_KEYS} and
{@see FormDataFlag::PRESERVE_STRING_KEYS} are applied by default.
Implemented by
|
#
|
public
|
withJsonDecodeFlags(
int-mask-of<JSON_BIGINT_AS_STRING|JSON_INVALID_UTF8_IGNORE|JSON_INVALID_UTF8_SUBSTITUTE|JSON_OBJECT_AS_ARRAY|JSON_THROW_ON_ERROR> $flags,
): static
Get an instance with the given json_decode() flags
Get an instance with the given json_decode() flags
{@see \JSON_OBJECT_AS_ARRAY} is applied by default.
{@see \JSON_THROW_ON_ERROR} is always applied and cannot be disabled.
Implemented by
|
#
|
public
|
withMiddleware(
CurlerMiddlewareInterface|HttpRequestHandlerInterface|(Closure(RequestInterface $request, Closure(RequestInterface): HttpResponseInterface $next, CurlerInterface $curler): ResponseInterface) $middleware,
?string $name = null,
): static
Get an instance with the given middleware applied to the request handler
stack
Get an instance with the given middleware applied to the request handler
stack
Implemented by
|
#
|
public
|
withoutMiddleware(CurlerMiddlewareInterface|HttpRequestHandlerInterface|Closure|string $middleware): static
Get an instance where the given middleware is not applied to requests
Get an instance where the given middleware is not applied to requests
Implemented by
|
#
|
public
|
getPager(): ?CurlerPagerInterface
Get the endpoint's pagination handler
Get the endpoint's pagination handler
Implemented by
|
#
|
public
|
alwaysPaginates(): bool
Check if the endpoint's pagination handler is used to process every
request
Check if the endpoint's pagination handler is used to process every
request
Implemented by
|
#
|
public
|
withPager(?CurlerPagerInterface $pager, bool $alwaysPaginate = false): static
Get an instance with the given pagination handler
Get an instance with the given pagination handler
Parameters
$alwaysPaginate |
If true , the pager is used to process
requests even if no pagination is required.
|
Implemented by
|
#
|
public
|
getCacheStore(): ?CacheInterface
Get the endpoint's cache store
Get the endpoint's cache store
Implemented by
|
#
|
public
|
withCacheStore(?CacheInterface $store = null): static
Get an instance with the given cache store
Get an instance with the given cache store
If no $store is given, cookies and responses are cached in the default
cache store as needed.
Implemented by
|
#
|
public
|
hasCookies(): bool
Check if the instance handles cookies
Check if the instance handles cookies
Implemented by
|
#
|
public
|
withCookies(?string $cacheKey = null): static
Get an instance that handles cookies
Get an instance that handles cookies
Implemented by
|
#
|
public
|
withoutCookies(): static
Get an instance that does not handle cookies
Get an instance that does not handle cookies
Implemented by
|
#
|
public
|
hasResponseCache(): bool
Check if response caching is enabled
Check if response caching is enabled
Implemented by
|
#
|
public
|
withResponseCache(bool $cacheResponses = true): static
Get an instance that caches responses to GET and HEAD requests
Get an instance that caches responses to GET and HEAD requests
HTTP caching headers are ignored. USE RESPONSIBLY.
Implemented by
|
#
|
public
|
hasPostResponseCache(): bool
Check if POST response caching is enabled
Check if POST response caching is enabled
Implemented by
|
#
|
public
|
withPostResponseCache(bool $cachePostResponses = true): static
Get an instance that caches responses to repeatable POST requests
Get an instance that caches responses to repeatable POST requests
{@see withResponseCache()} must also be called to enable caching.
Implemented by
|
#
|
public
|
withCacheKeyCallback(
(callable(RequestInterface $request, CurlerInterface $curler): (string[]|string))|null $callback,
): static
Get an instance that uses a callback to generate response cache keys
Get an instance that uses a callback to generate response cache keys
The callback's return value is hashed and combined with request method
and URI to create a response cache key.
Implemented by
|
#
|
public
|
getCacheLifetime(): int<-1, max>
Get the lifetime of cached responses, in seconds
Get the lifetime of cached responses, in seconds
Implemented by
|
#
|
public
|
withCacheLifetime(int<-1, max> $seconds): static
Get an instance where cached responses expire after the given number of
seconds
Get an instance where cached responses expire after the given number of
seconds
3600 is applied by default.
{@see withResponseCache()} must also be called to enable caching.
Parameters
$seconds |
-
0 : cache responses indefinitely
-
-1 : disable caching until the method is called again with $seconds
greater than or equal to 0
|
Implemented by
|
#
|
public
|
refreshesCache(): bool
Check if the instance replaces cached responses even if they haven't
expired
Check if the instance replaces cached responses even if they haven't
expired
Implemented by
|
#
|
public
|
withRefreshCache(bool $refresh = true): static
Get an instance that replaces cached responses even if they haven't
expired
Get an instance that replaces cached responses even if they haven't
expired
Implemented by
|
#
|
public
|
getTimeout(): int<0, max>|null
Get the connection timeout applied to the instance, in seconds
Get the connection timeout applied to the instance, in seconds
Implemented by
|
#
|
public
|
withTimeout(int<0, max>|null $seconds): static
Get an instance with the given connection timeout
Get an instance with the given connection timeout
Parameters
$seconds |
-
0 : wait indefinitely
-
null (default): use the underlying client's default connection
timeout
|
Implemented by
|
#
|
public
|
followsRedirects(): bool
Check if the instance follows "Location" headers
Check if the instance follows "Location" headers
Implemented by
|
#
|
public
|
withFollowRedirects(bool $follow = true): static
Get an instance that follows "Location" headers
Get an instance that follows "Location" headers
Implemented by
|
#
|
public
|
getMaxRedirects(): int<-1, max>|null
Get the maximum number of "Location" headers followed
Get the maximum number of "Location" headers followed
Implemented by
|
#
|
public
|
withMaxRedirects(int<-1, max>|null $redirects): static
Get an instance that limits the number of "Location" headers followed
Get an instance that limits the number of "Location" headers followed
Parameters
$redirects |
-
-1 : allow unlimited redirects
-
0 : disable redirects (same effect as withFollowRedirects(false) )
-
null (default): use the underlying client's default redirect limit
|
Implemented by
|
#
|
public
|
getRetryAfterTooManyRequests(): bool
Check if the instance retries throttled requests when the endpoint
returns a "Retry-After" header
Check if the instance retries throttled requests when the endpoint
returns a "Retry-After" header
Implemented by
|
#
|
public
|
getRetryAfterMaxSeconds(): int<0, max>
Get the maximum delay between request attempts
Get the maximum delay between request attempts
Implemented by
|
#
|
public
|
withRetryAfterTooManyRequests(bool $retry = true): static
Get an instance that retries throttled requests when the endpoint returns
a "Retry-After" header
Get an instance that retries throttled requests when the endpoint returns
a "Retry-After" header
Implemented by
|
#
|
public
|
withRetryAfterMaxSeconds(int<0, max> $seconds): static
Get an instance that limits the delay between request attempts
Get an instance that limits the delay between request attempts
300 is applied by default.
Parameters
$seconds |
If 0 , unlimited delays are allowed.
|
Implemented by
|
#
|
public
|
throwsHttpErrors(): bool
Check if exceptions are thrown for HTTP errors
Check if exceptions are thrown for HTTP errors
Implemented by
|
#
|
public
|
withThrowHttpErrors(bool $throw = true): static
Get an instance that throws exceptions for HTTP errors
Get an instance that throws exceptions for HTTP errors
Implemented by
|
#
|
public
|
replaceQuery<T is RequestInterface|UriInterface|Stringable|string>(
T $value,
mixed[] $query,
): (T is RequestInterface|UriInterface ? T : UriInterface)
Use the form data flags and date formatter applied to the instance to
replace the query string of a request or URI
Use the form data flags and date formatter applied to the instance to
replace the query string of a request or URI
Implemented by
|
#
|