|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00031 class Zend_Server_Reflection_Node 00032 { 00037 protected $_value = null; 00038 00043 protected $_children = array(); 00044 00049 protected $_parent = null; 00050 00058 public function __construct($value, Zend_Server_Reflection_Node $parent = null) 00059 { 00060 $this->_value = $value; 00061 if (null !== $parent) { 00062 $this->setParent($parent, true); 00063 } 00064 00065 return $this; 00066 } 00067 00076 public function setParent(Zend_Server_Reflection_Node $node, $new = false) 00077 { 00078 $this->_parent = $node; 00079 00080 if ($new) { 00081 $node->attachChild($this); 00082 return; 00083 } 00084 } 00085 00093 public function createChild($value) 00094 { 00095 $child = new self($value, $this); 00096 00097 return $child; 00098 } 00099 00106 public function attachChild(Zend_Server_Reflection_Node $node) 00107 { 00108 $this->_children[] = $node; 00109 00110 if ($node->getParent() !== $this) { 00111 $node->setParent($this); 00112 } 00113 } 00114 00120 public function getChildren() 00121 { 00122 return $this->_children; 00123 } 00124 00130 public function hasChildren() 00131 { 00132 return count($this->_children) > 0; 00133 } 00134 00140 public function getParent() 00141 { 00142 return $this->_parent; 00143 } 00144 00150 public function getValue() 00151 { 00152 return $this->_value; 00153 } 00154 00161 public function setValue($value) 00162 { 00163 $this->_value = $value; 00164 } 00165 00175 public function getEndPoints() 00176 { 00177 $endPoints = array(); 00178 if (!$this->hasChildren()) { 00179 return $endPoints; 00180 } 00181 00182 foreach ($this->_children as $child) { 00183 $value = $child->getValue(); 00184 00185 if (null === $value) { 00186 $endPoints[] = $this; 00187 } elseif ((null !== $value) 00188 && $child->hasChildren()) 00189 { 00190 $childEndPoints = $child->getEndPoints(); 00191 if (!empty($childEndPoints)) { 00192 $endPoints = array_merge($endPoints, $childEndPoints); 00193 } 00194 } elseif ((null !== $value) && !$child->hasChildren()) { 00195 $endPoints[] = $child; 00196 } 00197 } 00198 00199 return $endPoints; 00200 } 00201 }