[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/php-ai-client/src/Providers/Http/DTO/ -> Request.php (summary)

(no description)

File Size: 377 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Request:: (19 methods):
  __construct()
  __clone()
  getMethod()
  getUri()
  getHeaders()
  getHeader()
  getHeaderAsString()
  hasHeader()
  getBody()
  getContentType()
  withHeader()
  withData()
  getData()
  getOptions()
  withOptions()
  getJsonSchema()
  toArray()
  fromArray()
  fromPsrRequest()


Class: Request  - X-Ref

Represents an HTTP request.

This class encapsulates HTTP request data that can be converted
to PSR-7 requests by the HTTP transporter.

__construct(HttpMethodEnum $method, string $uri, array $headers = [], $data = null, ?\WordPress\AiClient\Providers\Http\DTO\RequestOptions $options = null)   X-Ref
Constructor.

param: HttpMethodEnum $method The HTTP method.
param: string $uri The request URI.
param: array<string, string|list<string>> $headers The request headers.
param: string|array<string, mixed>|null $data The request data.
param: RequestOptions|null $options The request transport options.

__clone()   X-Ref
Creates a deep clone of this request.

Clones the headers collection and request options to ensure
the cloned request is independent of the original.
The HTTP method enum is immutable and can be safely shared.


getMethod()   X-Ref
Gets the HTTP method.

return: HttpMethodEnum The HTTP method.

getUri()   X-Ref
Gets the request URI.

For GET requests with array data, appends the data as query parameters.

return: string The URI.

getHeaders()   X-Ref
Gets the request headers.

return: array<string, list<string>> The headers.

getHeader(string $name)   X-Ref
Gets a specific header value.

return: list<string>|null The header value(s) or null if not found.
param: string $name The header name (case-insensitive).

getHeaderAsString(string $name)   X-Ref
Gets header values as a comma-separated string.

return: string|null The header values as a comma-separated string, or null if not found.
param: string $name The header name (case-insensitive).

hasHeader(string $name)   X-Ref
Checks if a header exists.

return: bool True if the header exists, false otherwise.
param: string $name The header name (case-insensitive).

getBody()   X-Ref
Gets the request body.

For GET requests, returns null.
For POST/PUT/PATCH requests:
- If body is set, returns it as-is
- If data is set and Content-Type is JSON, returns JSON-encoded data
- If data is set and Content-Type is form, returns URL-encoded data

return: string|null The body.

getContentType()   X-Ref
Gets the Content-Type header value.

return: string|null The Content-Type header value or null if not set.

withHeader(string $name, $value)   X-Ref
Returns a new instance with the specified header.

return: self A new instance with the header.
param: string $name The header name.
param: string|list<string> $value The header value(s).

withData($data)   X-Ref
Returns a new instance with the specified data.

return: self A new instance with the data.
param: string|array<string, mixed> $data The request data.

getData()   X-Ref
Gets the request data array.

return: array<string, mixed>|null The request data array.

getOptions()   X-Ref
Gets the request options.

return: RequestOptions|null Request transport options when configured.

withOptions(?\WordPress\AiClient\Providers\Http\DTO\RequestOptions $options)   X-Ref
Returns a new instance with the specified request options.

return: self A new instance with the options.
param: RequestOptions|null $options The request options to apply.

getJsonSchema()   X-Ref
{@inheritDoc}


toArray()   X-Ref
{@inheritDoc}

return: RequestArrayShape

fromArray(array $array)   X-Ref
{@inheritDoc}


fromPsrRequest(RequestInterface $psrRequest)   X-Ref
Creates a Request instance from a PSR-7 RequestInterface.

return: self A new Request instance.
param: RequestInterface $psrRequest The PSR-7 request to convert.



Generated : Sat Jun 13 09:38:55 2026 Cross-referenced by PHPXref