Example #1
0
 /**
  * mutator method for profile creation date
  *
  * @param \DateTime|null $newProfileCreateDate
  *
  *
  */
 public function setProfileCreateDate($newProfileCreateDate = null)
 {
     if ($newProfileCreateDate === null) {
         $this->profileCreateDate = new \DateTime();
         return;
     }
     // save the profile creation date
     try {
         $newProfileCreateDate = ValidateDate::validateDate($newProfileCreateDate);
     } catch (\InvalidArgumentException $invalidArgument) {
         throw new \InvalidArgumentException($invalidArgument->getMessage(), 0, $invalidArgument);
     } catch (\RangeException $range) {
         throw new \RangeException($range->getMessage(), 0, $range);
     }
     // save date
     $this->profileCreateDate = $newProfileCreateDate;
 }
Example #2
0
 /**
  * mutator method for comment date
  *
  * @param \DateTime|null $newCommentDate
  * @throws \InvalidArgumentException if $newCommentDate is not a valid object or string
  * @throws \RangeException if $newCommentDate is a date that cannot exist
  **/
 public function setCommentDate($newCommentDate = null)
 {
     //base case: if $newCommentDate is null, use current date and time
     if ($newCommentDate === null) {
         $this->commentDate = new \DateTime();
         return;
     }
     //store the comment date
     try {
         $newCommentDate = ValidateDate::validateDate($newCommentDate);
     } catch (\InvalidArgumentException $invalidArgument) {
         throw new \InvalidArgumentException($invalidArgument->getMessage(), 0, $invalidArgument);
     } catch (\RangeException $range) {
         throw new \RangeException($range->getMessage(), 0, $range);
     }
     $this->commentDate = $newCommentDate;
 }