xpath = explode(XmlBuilder::SLASH, $xpath); $this->pointer = count($this->xpath) - 1; $this->added = false; } public function getCurrent() { return implode(XmlBuilder::SLASH, array_slice($this->xpath, 0, $this->pointer + 1)); } public function toRoot() { if ($this->pointer === 0) { return false; } else { $this->pointer--; return true; } } public function fromRoot() { if ($this->pointer === count($this->xpath) - 1) { return false; } else { $this->pointer++; return true; } } public function isLastNode() { return count($this->xpath) - 1 === $this->pointer; } public function getNext() { return !$this->isLastNode() ? $this->xpath[$this->pointer + 1] : null; } public function isNextLast() { return count($this->xpath) - 1 === $this->pointer + 1; } public function setAdded() { $this->added = true; return $this; } public function isAdded() { $this->added; } }