Axiom (v1.2.0)

A lightweight PHP framework
H:/Workspace/php-axiom/www/php-axiom/libraries/axiom/axTreeItem.class.php
Go to the documentation of this file.
00001 <?php
00018 class axTreeItem implements ArrayAccess, Iterator {
00019 
00024     protected $_v;
00025 
00030     protected $_c;
00031 
00037     public function setValue ($v) {
00038         $this->_v = $v;
00039         return $this;
00040     }
00041 
00046     public function getValue () {
00047         return isset($this->_v) ? $this->_v : null;
00048     }
00049     
00055     public function __isset ($k) {
00056         return isset($this->_c[$k]);
00057     }
00058     
00068     public function __get ($k) {
00069         if (isset($this->_c[$k]))
00070             return $this->_c[$k];
00071         return $this->_c[$k] = new self;
00072     }
00073                 
00080     public function __set ($k,$v) {
00081                 $this->__get($k)->setValue($v);
00082     }
00083     
00089     public function __unset ($k) {
00090         unset($this->_c[$k]);
00091     }
00092     
00099     public function offsetExists($k) {
00100                 return $this->__isset($k);
00101     }
00102     
00109     public function offsetGet ($k) {
00110                 return $this->__get($k);
00111     }
00112     
00120     public function offsetSet ($k,$v) {
00121                 $this->__set($k,$v);
00122     }
00123     
00130     public function offsetUnset ($k) {
00131                 $this->__unset($k);
00132     }
00133     
00139     public function current () {
00140                 return current($this->_c);
00141     }
00142     
00148     public function key () {
00149                 return key($this->_c);
00150     }
00151     
00157     public function next () {
00158                 next($this->_c);
00159     }
00160     
00166     public function rewind () {
00167                 reset($this->_c);
00168     }
00169     
00175     public function valid () {
00176                 return (bool)current($this->_c);
00177     }
00178                 
00186     public function __toString () {
00187         return (string)$this->getValue();
00188     }
00189     
00197     public static function __set_state ($props) {
00198                 $tree = new self;
00199                 $tree->_v = $props['_v'];
00200                 $tree->_c = $props['_c'];
00201                 return $tree;
00202     }
00203 }
 All Data Structures Files Functions Variables