addType('id', Types::INTEGER); $this->addType('file_id', Types::INTEGER); $this->addType('timestamp', Types::INTEGER); $this->addType('size', Types::INTEGER); $this->addType('mimetype', Types::INTEGER); $this->addType('metadata', Types::JSON); } public function jsonSerialize(): array { return [ 'id' => $this->id, 'file_id' => $this->fileId, 'timestamp' => $this->timestamp, 'size' => $this->size, 'mimetype' => $this->mimetype, 'metadata' => $this->metadata, ]; } /** * @abstract given a key, return the value associated with the key in the metadata column * if nothing is found, we return an empty string * @param string $key key associated with the value */ public function getMetadataValue(string $key): ?string { return $this->metadata[$key] ?? null; } /** * @abstract sets a key value pair in the metadata column * @param string $key key associated with the value * @param string $value value associated with the key */ public function setMetadataValue(string $key, string $value): void { $this->metadata[$key] = $value; $this->markFieldUpdated('metadata'); } }