XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
PropertyList.php
Go to the documentation of this file.
1 <?php
2 
7 {
11  protected $data = array();
12 
16  protected $parent;
17 
18  protected $cache;
19 
20  public function __construct($parent = null) {
21  $this->parent = $parent;
22  }
23 
27  public function get($name) {
28  if ($this->has($name)) return $this->data[$name];
29  // possible performance bottleneck, convert to iterative if necessary
30  if ($this->parent) return $this->parent->get($name);
31  throw new HTMLPurifier_Exception("Key '$name' not found");
32  }
33 
37  public function set($name, $value) {
38  $this->data[$name] = $value;
39  }
40 
44  public function has($name) {
45  return array_key_exists($name, $this->data);
46  }
47 
52  public function reset($name = null) {
53  if ($name == null) $this->data = array();
54  else unset($this->data[$name]);
55  }
56 
62  public function squash($force = false) {
63  if ($this->cache !== null && !$force) return $this->cache;
64  if ($this->parent) {
65  return $this->cache = array_merge($this->parent->squash($force), $this->data);
66  } else {
67  return $this->cache = $this->data;
68  }
69  }
70 
74  public function getParent() {
75  return $this->parent;
76  }
77 
81  public function setParent($plist) {
82  $this->parent = $plist;
83  }
84 }
85 
86 // vim: et sw=4 sts=4