Example #1
0
 /**
  * Returns the previous and next published posts' title and id, if they exist.
  * 
  * @param int $postId
  * @return array[]
  */
 public function getClosestPosts($postId)
 {
     if (!is_int($postId)) {
         throw new \InvalidArgumentException('Post id must be an integer');
     }
     $result = $this->postMapper->getClosestPosts($postId);
     return array('preceding_post' => json_decode($result['preceding_post']), 'following_post' => json_decode($result['following_post']));
 }