File::toArray(): WordPressAiClientFilesDTOFileArrayShape

In this article

{@inheritDoc}

Return

WordPressAiClientFilesDTOFileArrayShape

Source

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

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

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