Request::toArray(): WordPressAiClientProvidersHttpDTORequestArrayShape

In this article

{@inheritDoc}

Return

WordPressAiClientProvidersHttpDTORequestArrayShape

Source

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;
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.