public function chunk(Element $element) { $size = $element->getAttribute('data-size')->getValue(); $chunks = array_map(function ($chunk) { return new ListModel($chunk); }, array_chunk($this->item, $size)); return $chunks; }
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(); }
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 . '/>'; } }
private function wrapAsset(Element $element, $attributeName) { $attribute = $element->getAttribute($attributeName); if (!$attribute) { return; } $url = Url::fromString($attribute->getValue()); if ($url->isAbsolute()) { return; } $path = $url->getPath(); $path->insertAll($this->path->slice(0, -1), 0); $url->setPath($path); $element->setAttribute($attributeName, $url->toString()); }
private function thenTheFootShouldBe($string) { $printer = new Printer(); $footerContent = $printer->printNodes($this->dom->findChildElement('html')->findChildElement('body')->findChildElement('footer')->getChildren()); $this->assertEquals($string, $footerContent); }
private function getPropertyName(Element $element) { return $element->getAttribute('property')->getValue(); }
private function copyChildren(Element $copy) { foreach ($this->children as $child) { if ($child instanceof Element) { $copy->getChildren()->append($child->copy()); } else { if ($child instanceof Text) { $copy->getChildren()->append(new Text($child->getText())); } } } }