Example #1
0
 /**
  * Calculates the depth on each call.
  *
  * It will return at least 1 if the subject node as no children.
  *
  * @return int
  */
 public function depth()
 {
     if (!$this->node->hasChildren()) {
         return 1;
     }
     $depths = array();
     foreach ($this->node->getIterator() as $subnode) {
         $depths[] = $subnode->depth();
     }
     return max($depths) + 1;
 }