WordPress\AiClient\Providers\Http\DTO

Response::getData │ public │ WP 0.1.0

Gets the response data as an array.

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

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

Хуков нет.

Возвращает

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

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

$Response = new Response();
$Response->getData(): ?array;

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

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

Код Response::getData() WP 7.1.2

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