HTMLPurifier 4.4.0
/home/ezyang/Dev/htmlpurifier/library/HTMLPurifier/PropertyList.php
Go to the documentation of this file.
00001 <?php
00002 
00006 class HTMLPurifier_PropertyList
00007 {
00011     protected $data = array();
00012 
00016     protected $parent;
00017 
00018     protected $cache;
00019 
00020     public function __construct($parent = null) {
00021         $this->parent = $parent;
00022     }
00023 
00027     public function get($name) {
00028         if ($this->has($name)) return $this->data[$name];
00029         // possible performance bottleneck, convert to iterative if necessary
00030         if ($this->parent) return $this->parent->get($name);
00031         throw new HTMLPurifier_Exception("Key '$name' not found");
00032     }
00033 
00037     public function set($name, $value) {
00038         $this->data[$name] = $value;
00039     }
00040 
00044     public function has($name) {
00045         return array_key_exists($name, $this->data);
00046     }
00047 
00052     public function reset($name = null) {
00053         if ($name == null) $this->data = array();
00054         else unset($this->data[$name]);
00055     }
00056 
00062     public function squash($force = false) {
00063         if ($this->cache !== null && !$force) return $this->cache;
00064         if ($this->parent) {
00065             return $this->cache = array_merge($this->parent->squash($force), $this->data);
00066         } else {
00067             return $this->cache = $this->data;
00068         }
00069     }
00070 
00074     public function getParent() {
00075         return $this->parent;
00076     }
00077 
00081     public function setParent($plist) {
00082         $this->parent = $plist;
00083     }
00084 }
00085 
00086 // vim: et sw=4 sts=4