WordPress\AiClient\Messages\DTO
MessagePart::toArray
{@inheritDoc}
Метод класса: MessagePart{}
Хуков нет.
Возвращает
MessagePartArrayShape.
Использование
$MessagePart = new MessagePart(); $MessagePart->toArray(): array;
Список изменений
| С версии 0.1.0 | Введена. |
Код MessagePart::toArray() MessagePart::toArray WP 7.1.2
public function toArray(): array
{
$data = [self::KEY_CHANNEL => $this->channel->value, self::KEY_TYPE => $this->type->value];
if ($this->text !== null) {
$data[self::KEY_TEXT] = $this->text;
} elseif ($this->file !== null) {
$data[self::KEY_FILE] = $this->file->toArray();
} elseif ($this->functionCall !== null) {
$data[self::KEY_FUNCTION_CALL] = $this->functionCall->toArray();
} elseif ($this->functionResponse !== null) {
$data[self::KEY_FUNCTION_RESPONSE] = $this->functionResponse->toArray();
} else {
throw new RuntimeException('MessagePart requires one of: text, file, functionCall, or functionResponse. ' . 'This should not be a possible condition.');
}
if ($this->thoughtSignature !== null) {
$data[self::KEY_THOUGHT_SIGNATURE] = $this->thoughtSignature;
}
return $data;
}