WordPress\AiClient\Providers\Http\DTO
Request::fromPsrRequest
Creates a Request instance from a PSR-7 RequestInterface.
Метод класса: Request{}
Хуков нет.
Возвращает
self. A new Request instance.
Использование
$result = Request::fromPsrRequest( $psrRequest ): self;
- $psrRequest(RequestInterface) (обязательный)
- The PSR-7 request to convert.
Список изменений
| С версии 0.2.0 | Введена. |
Код Request::fromPsrRequest() Request::fromPsrRequest WP 7.1.4
public static function fromPsrRequest(RequestInterface $psrRequest): self
{
$method = HttpMethodEnum::from($psrRequest->getMethod());
$uri = (string) $psrRequest->getUri();
// Convert PSR-7 headers to array format expected by our constructor
/** @var array<string, list<string>> $headers */
$headers = $psrRequest->getHeaders();
// Get body content
$body = $psrRequest->getBody()->getContents();
$bodyOrData = !empty($body) ? $body : null;
return new self($method, $uri, $headers, $bodyOrData);
}