persistence = $persistence; } public function generateId(): PostId { return PostId::fromInt($this->persistence->generateId()); } public function findById(PostId $id): Post { try { $arrayData = $this->persistence->retrieve($id->toInt()); } catch (\OutOfBoundsException $e) { throw new \OutOfBoundsException(sprintf('Post with id %d does not exist', $id->toInt()), 0, $e); } return Post::fromState($arrayData); } public function save(Post $post) { $this->persistence->persist([ 'id' => $post->getId()->toInt(), 'statusId' => $post->getStatus()->toInt(), 'text' => $post->getText(), 'title' => $post->getTitle(), ]); } }