Axiom (v1.2.0)

A lightweight PHP framework
H:/Workspace/php-axiom/www/php-axiom/libraries/axiom/axFeedEntry.class.php
Go to the documentation of this file.
00001 <?php
00017 class axFeedEntry {
00018     
00023                 protected $_id;
00024                 
00029                 protected $_title;
00030                 
00035                 protected $_date;
00036                 
00041                 protected $_author;
00042                 
00047                 protected $_decription;
00048                 
00053                 protected $content;
00054 
00059                 protected $link;
00060     
00065                 protected $comments;
00066                 
00074                 public function __construct (array $values = array()) {
00075                     if (!empty($values)) {
00076                         foreach ($values as $key => $value) {
00077                 $this->$key = $value;
00078                         }
00079                     }
00080                 }
00081                 
00089     public function __get ($key) {
00090         if (method_exists($this, $method = "get" . ucfirst($key)))
00091             return $this->$method();
00092         else
00093             throw new InvalidArgumentException("$key does not exist", 4001);
00094     }
00095     
00103     public function __set ($key, $value) {
00104         if (method_exists($this, $method = "get" . ucfirst($key)))
00105             return $this->$method($value);
00106         else
00107             throw new InvalidArgumentException("$key does not exist", 4001);
00108     }
00109     
00114     public function getId () {
00115         return $this->_id;
00116     }
00117     
00126     public function setId ($id) {
00127         $this->_id = (int)$id;
00128         return $this;
00129     }
00130     
00136     public function getTitle () {
00137         return $this->_title;
00138     }
00139     
00146     public function setTitle ($title) {
00147         $title = strip_tags($title);
00148         $this->_title = $title;
00149         return $this;
00150     }
00151     
00156     public function getDate () {
00157         return $this->_date;
00158     }
00159     
00168     public function setDate ($date) {
00169         if ($time = strtotime($date))
00170             $date = date('r', $time);
00171         else
00172             throw new InvalidArgumentException("Invalid date format", 4002);
00173             
00174         $this->_date = $date;
00175         return $this;
00176     }
00177     
00183     public function getAuthor () {
00184         return $this->_author;
00185     }
00186     
00194     public function setAuthor (array $author) {
00195         $author = array_intersect_key($author, array_flip(array('mail', 'name', 'uri')));
00196         
00197         if (isset($author['mail']) && !axMail::validateEmail($author['mail']))
00198             throw new InvalidArgumentException("Invalid author email", 4003);
00199             
00200         if (isset($author['name']) && !$author['name'] = filter_var($author['name'], FILTER_SANITIZE_ENCODED))
00201             throw new InvalidArgumentException("Invalid author name", 4004);
00202             
00203         if (isset($author['uri']) && !filter_var($author['uri'], FILTER_VALIDATE_URL))
00204             throw new InvalidArgumentException("Invalid URI for author", 4005);
00205             
00206         if (empty($author))
00207             throw new InvalidArgumentException("Author description must contain at least a name or email or URI", 4006);
00208             
00209         $this->_author = $author;
00210         return $this;
00211     }
00212     
00218     public function getDescription () {
00219         return $this->_description;
00220     }
00221     
00228     public function setDescription ($description) {
00229         $description = strip_tags($description);
00230         $this->_description = $description;
00231         return $this;
00232     }
00233     
00239     public function getContent () {
00240         return $this->content;
00241     }
00242     
00249     public function setContent ($content) {
00250         $this->content = $content;
00251         return $this;
00252     }
00253     
00259     public function getLink () {
00260         return $this->link;
00261     }
00262     
00270     public function setLink ($url) {
00271         if (!$url = filter_var($url, FILTER_VALIDATE_URL))
00272             throw new InvalidArgumentException("Invalid URL", 4007);
00273         $this->link = $url;
00274         return $this;
00275     }
00276     
00282     public function getComments () {
00283         return $this->comments;
00284     }
00285     
00293     public function setComments ($url) {
00294         if (!$url = filter_var($url, FILTER_VALIDATE_URL))
00295             throw new InvalidArgumentException("Invalid URL", 4007);
00296         $this->comments = $url;
00297         return $this;
00298     }
00299 }
 All Data Structures Files Functions Variables