WordPress\AiClient\Files\DTO

File::toArraypublicWP 0.1.0

{@inheritDoc}

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

Хуков нет.

Возвращает

FileArrayShape.

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

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

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

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

Код File::toArray() WP 7.0

public function toArray(): array
{
    $data = [self::KEY_FILE_TYPE => $this->fileType->value, self::KEY_MIME_TYPE => $this->getMimeType()];
    if ($this->url !== null) {
        $data[self::KEY_URL] = $this->url;
    } elseif (!$this->fileType->isRemote() && $this->base64Data !== null) {
        $data[self::KEY_BASE64_DATA] = $this->base64Data;
    } else {
        throw new RuntimeException('File requires either url or base64Data. This should not be a possible condition.');
    }
    return $data;
}