Example #1
0
 function let()
 {
     $this->commentId = CommentId::generate();
     $this->postId = PostId::generate();
     $this->author = 'Rochelle';
     $this->content = 'Comment';
     $this->creatingDate = new \DateTime();
     $this->beConstructedWith($this->commentId, $this->postId, $this->author, $this->content, $this->creatingDate);
 }
Example #2
0
 /**
  * @param PostId $postId
  * @param string $author
  * @param string $content
  * @return Comment
  */
 public static function create(PostId $postId, $author, $content)
 {
     $comment = new self($commentId = CommentId::generate());
     $comment->setPostId($postId);
     $comment->setAuthor($author);
     $comment->setContent($content);
     $comment->setCreatingDate($creatingDate = new \DateTime());
     $comment->recordThat(new CommentWasAdded($commentId, $postId, $author, $content, $creatingDate));
     return $comment;
 }