Exemple #1
0
 /**
  * @throws \InvalidArgumentException
  * @return Post
  */
 public function build()
 {
     if (is_null($this->title)) {
         throw new \InvalidArgumentException('Need to set title');
     }
     if (is_null($this->text)) {
         throw new \InvalidArgumentException('Need to set text');
     }
     if (is_null($this->createTime)) {
         throw new \InvalidArgumentException('Need to set createTime');
     }
     if (is_null($this->status)) {
         throw new \InvalidArgumentException('Need to set status');
     }
     $item = new Post();
     $item->setTitle($this->title);
     $item->setSubTitle($this->subTitle);
     $item->setText($this->text);
     $item->setCreateTime($this->createTime);
     $item->setStatus($this->status);
     $item->setCanComment($this->canComment);
     return $item;
 }
Exemple #2
0
 /**
  * @param Post $item
  * @return array
  */
 protected function getUpdateBindings($item)
 {
     return array(':title' => $item->getTitle(), ':subTitle' => $item->getSubTitle(), ':text' => $item->getText(), ':createTime' => $item->getCreateTime(), ':status' => $item->getStatus(), ':canComment' => $item->getCanComment());
 }