Advertisement
Guest User

Entity

a guest
May 26th, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.53 KB | None | 0 0
  1. <?php
  2. class Article {
  3.  
  4.     const STATUS_DRAFT = 1;
  5.     const STATUS_PUBLISHED = 2;
  6.  
  7.     private $status;
  8.     private $publishDate;
  9.     private $viewCount;
  10.     private $title;
  11.     private $id;
  12.  
  13.     public function __construct() {
  14.         $this->status = static::STATUS_DRAFT;
  15.         $this->viewCount = 0;
  16.     }
  17.    
  18.     public function setId($id)
  19.     {
  20.         $this->id = $id;
  21.     }
  22.  
  23.     public function setPublished(DateTime $date) {
  24.         $this->status = static::STATUS_PUBLISHED;
  25.         $this->publishDate = $date;
  26.     }
  27.    
  28.     public function setStatus($status)
  29.     {
  30.         $this->status = $status;
  31.     }
  32.    
  33.     public function setPublishDate(DateTIme $date)
  34.     {
  35.         $this->publishDate = $date;
  36.     }
  37.  
  38.     public function setTitle($title)
  39.     {
  40.         $this->title = $title;
  41.     }
  42.    
  43.     public function setContent($content)
  44.     {
  45.         $this->content = $content;
  46.     }
  47.    
  48.     public function getStatus()
  49.     {
  50.         return $this->status;
  51.     }
  52.    
  53.     public function getPublishDate()
  54.     {
  55.         return $this->publishDate;
  56.     }
  57.    
  58.     public function getTitle()
  59.     {
  60.         return $this->title;
  61.     }
  62.    
  63.     public function getContent()
  64.     {
  65.         return $this->content;
  66.     }
  67.    
  68.     public function getId()
  69.     {
  70.         return $this->id;
  71.     }
  72.    
  73.     public function toArray()
  74.     {
  75.         $out = array();
  76.         foreach($this as $key => $value)
  77.         {
  78.             $out[$key] = $value;
  79.         }
  80.         return $out;
  81.     }
  82.  
  83. }
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement