Newer
Older
<?php
include_once 'CompositeInterface.php';
/**
* Class AbstractComposite
*
* Date: 25.03.13
* Time: 10:05
* @author Thomas Joußen <tjoussen@databay.de>
*/
abstract class AbstractComposite implements CompositeInterface
{
/**
* @var AbstractComposite[]
*/
public $nodes = array();
/**
* Adds an CompositeInterface object to the node array which represents the condition tree structure
*
* @param CompositeInterface $node
*/
public function addNode(CompositeInterface $node)
{
$this->nodes[] = $node;
}
/**
* Describes a Composite tree Structure as human readable string
* @return string
*/
public function describe()
{
$description = "";
if (is_array($this->nodes)) {
if (\count($this->nodes) > 0) {
$description .= "(" . $this->nodes[0]->describe();
}
$description .= $this->getDescription();
if (\count($this->nodes) > 0) {
$description .= $this->nodes[1]->describe() . ") ";
}
}
return $description;
}