$this->id, "_sys" => json_encode($this->_sys), "_file" => json_encode($this->_file), "data" => json_encode($this->data), ]; } public static function fromDB(stdClass $data): Record { $file = json_decode($data->_file, true); if (!empty($file)) { $file = new File(...$file); } else { $file = null; } return new Record( id: $data->id, _sys: System::fromArray(json_decode($data->_sys, true)), data: new RecordData(json_decode($data->data, true)), _file: $file, ); } public function jsonSerialize(): static { return $this; } public static function fromArray(array $data): Record { $file = null; if (!empty($data["_file"])) { $file = File::fromArray($data["_file"]); } return new Record( id: $data["id"], _sys: System::fromArray($data["_sys"]), data: new RecordData($data["data"]), _file: $file, ); } }