Response::getData(): WordPressAiClientProvidersHttpDTOarray<string,

In this article

Gets the response data as an array.

Description

Attempts to decode the body as JSON. Returns null if the body is empty or not valid JSON.

Return

WordPressAiClientProvidersHttpDTOarray<string, mixed>|null The decoded data or null.

Source

public function getData(): ?array
{
    if ($this->body === null || $this->body === '') {
        return null;
    }
    $data = json_decode($this->body, \true);
    if (json_last_error() !== \JSON_ERROR_NONE) {
        return null;
    }
    /** @var array<string, mixed>|null $data */
    return is_array($data) ? $data : null;
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

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