createdBy = new NullAccount(); $this->createdAt = new \DateTimeImmutable('now'); } /** * Create history form model * * @param EditorDoc $doc Document * * @return self * * @since 1.0.0 */ public static function createFromDoc(EditorDoc $doc) : self { $hist = new self(); $hist->doc = $doc->id; $hist->createdBy = $doc->createdBy; $hist->title = $doc->title; $hist->plain = $doc->plain; $hist->content = $doc->content; $hist->version = $doc->version; return $hist; } /** * {@inheritdoc} */ public function toArray() : array { return [ 'id' => $this->id, 'title' => $this->title, 'plain' => $this->plain, 'content' => $this->content, 'createdAt' => $this->createdAt, 'createdBy' => $this->createdBy, ]; } /** * {@inheritdoc} */ public function __toString() { return (string) \json_encode($this->toArray()); } /** * {@inheritdoc} */ public function jsonSerialize() : mixed { return $this->toArray(); } }