예제 #1
0
파일: Tree.php 프로젝트: fewlines/core
 /**
  * Add the node to a position under the tree
  *
  * @param \SimpleXmlElement|Element $node
  * @param Element $parent
  */
 public function addChild($node, $parent = null)
 {
     if ($node instanceof \SimpleXmlElement) {
         $name = $node->getName();
         $attributes = (array) $node->attributes();
         $content = trim((string) $node);
         $element = new Element($name, $attributes, $content);
         if (!$this->tree) {
             $this->tree = $element;
         } else {
             if (!$parent) {
                 $parent = $this->tree;
             }
             $parent->addChild($element);
         }
         // Add child elements recursive
         if ($node->count() > 0) {
             foreach ($node as $childNode) {
                 $this->addChild($childNode, $element);
             }
         }
     } else {
         if ($node instanceof Element) {
             if (!$this->tree) {
                 $this->tree = $node;
             } else {
                 if (!$parent) {
                     $parent = $this->tree;
                 }
                 $parent->addChild($node);
             }
         }
     }
 }
예제 #2
0
파일: 036.php 프로젝트: badlamer/hhvm
 public function count()
 {
     echo "Called Count!\n";
     return parent::count();
 }