type = $type; } /** * @return array */ abstract protected function getContent(): array; /** * @return string */ public function serialize(): string { return json_encode([ $this->type, $this->getContent() ]); } }