Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2.  
  3. class Timestamp
  4. {
  5.     private $value;
  6.  
  7.     public function __construct($value)
  8.     {
  9.         $this->value = $value;
  10.     }
  11.  
  12.     public function updateTimestamps()
  13.     {
  14.         $this->value = new DateTime();
  15.         $this->touch();
  16.     }
  17.  
  18.     public function touch()
  19.     {
  20.         $this->value = new DateTime();
  21.     }
  22.  
  23.     public function getValue()
  24.     {
  25.         return $this->value;
  26.     }
  27. }
  28.  
  29. class User
  30. {
  31.     /**
  32.      * @var Timestamp
  33.      */
  34.     protected $createdAt;
  35.     /**
  36.      * @var Timestamp
  37.      */
  38.     protected $updatedAt;
  39.  
  40.     public function setCreateAt(Timestamp $timestamp)
  41.     {
  42.         $this->createdAt = $timestamp;
  43.     }
  44.  
  45.     poublic function getCreateAt()
  46.     {
  47.         return $this->createdA;
  48.     }
  49. }
  50.  
  51. $user = new User();
  52. $user->setCreateAt(new Timestamp(3123121));
  53. echo $user->getCreateAt()->touch()->getValue();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement