Source for file Leaf.class.php
Documentation is available at Leaf.class.php
* Gumbo Library Framework
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* Composite Pattern Leaf Class
* This class holds a single value (primitive type). It is only responsible
* for this data. It is the smallest element of the Tree, which means that
* no additional Branches can be added.
* To retrieve the value of a Leaf, simply use the 'get' method, or by using
* the overload method with any string (except 'name'):
* // the following will return the value
* $leaf->some_other_string_not_name;
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* @desc Composite Pattern Leaf Class
* Constructor, Creates new Leaf
* @param mix $val value of Leaf
* @param int|string$name name of Leaf
* Sets the value (use any key string)
public function __set ($name, $val) {
* Returns the value of the given element
* The parameter can either be the actual name of the Leaf object, or
* the actual property needed to be accessed ("name", "value"). Problems
* can occur if the $name of the Leaf actually is "name". Use getName () or
* getValue () for more specific access to values.
* @param int|string$name use 'name' to get the name or any string to retrieve the value
public function __get ($name) {
return $this->get ($name);
* Returns the corresponding Composite object or value (use 'name' for the Composite Name)
public function get ($name=
null) {
case "name" :
return $this->getName (); break;
* Adds a Composite object to the Composite (for Branch use only) (method does nothing)
* @param Gumbo_Interface_Composite $tree
* @param bool $replace replaces the original Composite object
public function add (Gumbo_Interface_Composite $tree, $replace=
false) {
* Removes a Composite object based on the Composite name (for Branch use only) (method does nothing)
public function remove ($name) {