예제 #1
0
 /**
  * Checks if current position is valid.
  *
  * @return bool Returns true on success, false otherwise
  */
 public function valid()
 {
     if (is_null($this->current)) {
         return true;
     }
     if ($this->current instanceof RecursiveLeafInterface) {
         return $this->current->valid();
     }
     return false;
 }
예제 #2
0
 /**
  * Injects leaf in crown of the tree.
  *
  * @param RecursiveLeafInterface $leaf      The leaf
  * @param int|string             $uniqueKey The unique key of leaf
  */
 protected function injectInCrown(RecursiveLeafInterface $leaf, $uniqueKey = null)
 {
     if (is_null($uniqueKey)) {
         $this->crown[] = null;
         $uniqueKey = key(array_slice($this->crown, -1, 1, true));
     }
     $leaf->setUniqueKey($uniqueKey);
     $this->crown[$uniqueKey] = $leaf;
 }