private function printElement(Element $node) { $out = '<' . $node->getName(); foreach ($node->getAttributes() as $attribute) { $out .= ' ' . $attribute->getName(); if ($attribute->getValue() !== null) { $quotes = $this->printQuotes($attribute->getQuoting()); $out .= '=' . $quotes . $attribute->getValue() . $quotes; } } if (!$node->getChildren()->isEmpty() || $node->hasClosingTag()) { return $out . '>' . $this->printNodes($node->getChildren()) . '</' . $node->getName() . '>'; } else { return $out . '/>'; } }
public function popElement() { if ($this->nextElement->getName() != $this->element->getName()) { throw new \Exception("Unmatched elements: {$this->element->getName()} and {$this->nextElement->getName()}"); } $this->element->setHasClosingTag(true); $this->element = $this->element->getParent(); $this->reset(); }