WordPress\AiClient\Providers\Http\DTO

Request::toArray │ public │ WP 0.1.0

{@inheritDoc}

Метод класса: Request{}

Хуков нет.

Возвращает

RequestArrayShape.

Использование

$Request = new Request();
$Request->toArray(): array;

Список изменений

С версии 0.1.0 Введена.

Код Request::toArray() WP 7.1.4

public function toArray(): array
{
    $array = [
        self::KEY_METHOD => $this->method->value,
        self::KEY_URI => $this->getUri(),
        // Include query params if GET with data
        self::KEY_HEADERS => $this->headers->getAll(),
    ];
    // Include body if present (getBody() handles the conversion)
    $body = $this->getBody();
    if ($body !== null) {
        $array[self::KEY_BODY] = $body;
    }
    if ($this->options !== null) {
        $optionsArray = $this->options->toArray();
        if (!empty($optionsArray)) {
            $array[self::KEY_OPTIONS] = $optionsArray;
        }
    }
    return $array;
}