check_target(); $result = []; $result['title'] = $this->target->title; $result['content'] = base64_encode($this->target->content); if ($this->target->has_id()) { $result['id'] = $this->target->get_id(); } return $result; } public function load_array(array $target) : self { $this->check_all_exists($target, [ 'title', 'content' ]); $this->target = new message($this->id_or_null($target)); $this->target->title = $target['title']; $this->target->content = base64_decode($target['content']); return $this; } }