WordPress\AiClient\Files\DTO

File::toArraypublicWP 0.1.0

{@inheritDoc}

Method of the class: File{}

No Hooks.

Returns

FileArrayShape.

Usage

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

Changelog

Since 0.1.0 Introduced.

File::toArray() code 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;
}