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