*/
trait HasChildElements
{
/** The element's children. */
protected ChildrenCollection $children;
/**
* Get the children elements.
*/
public function getChildren(): ChildrenCollection
{
return $this->children;
}
/**
* Set the children elements.
*
* @return $this
*/
public function setChildren(ChildrenCollection $children): static
{
$this->children = $children;
return $this;
}
/**
* Init the children elements.
*
* @return $this
*/
public function initChildren(): static
{
return $this->setChildren(new ChildrenCollection());
}
/**
* Alias for `addChild`.
*
* @return $this
*/
public function children(mixed $children, Closure|array|null $mapper = null): static
{
return $this->addChild($children, $mapper);
}
/**
* Add a child element to the parent.
*
* @return $this
*/
public function addChild(mixed $child, Closure|array|null $mapper = null): static
{
if ($child === null) {
return $this;
}
return tap(clone $this, function (HtmlElement $elt) use ($child, $mapper): void {
$elt->setChildren(
$elt->getChildren()->merge(ChildrenCollection::parse($child, $mapper))
);
});
}
/**
* Replace all children with an array of elements.
*
* @return $this
*/
public function setNewChildren(mixed $children, Closure|array|null $mapper = null): static
{
return tap(clone $this)
->initChildren()
->addChild($children, $mapper);
}
/**
* Alias for `prependChildren`.
*
* @return $this
*/
public function prependChild(mixed $children, Closure|array|null $mapper = null): static
{
return $this->prependChildren($children, $mapper);
}
/**
* Prepend children elements.
*
* @return $this
*/
public function prependChildren(mixed $children, Closure|array|null $mapper = null): static
{
return tap(clone $this, function (HtmlElement $elt) use ($children, $mapper): void {
$elt->getChildren()
->prepend(ChildrenCollection::parse($children, $mapper));
});
}
}
__halt_compiler();----SIGNATURE:----qapGXidtk+rEnOYn1KDK9PgiH/zKXvTcP7WqasK7mIo++dDPW481gOwqSFcpktgPrQh9iRSvSJyotlw+0upsKQc7ux37Mh02UaTc/dGgllYcutr8kGG3FrzyY9++79RQkv849GxGr9+UxTYAuO7QZ/7GqC3klFO0+WjLkqolQpn1wrBj4+4O7q82MW6ckdMcGWBZt4aka3ccnEfjeLLgtnA/WvIO8R2AHfasGq31R550mIlR35xZxyVM/GfFtPdphzsPMpkeTVCDp9Gs5Qh6Lzjq7n+OMS66duNOju2ayIRM6x+X/+T/QuspIDmR4mKfqtfW6ccSjRChj6PZDWfknScNTU29dSmv0EZFOCD9NeB7Ra5Xa29FWxelTFK5i5FBDkVo01G7Hb1ikK/ofFKswVtzrXf/zYz8Rv8ksj0hcZjY/m6bgWBM8spW2VXM68pGTDztuAxUoFRIEY/toSlqBT0R5U3NsaGuYQW+evtQadRVfAdcKH2x4tpBRcY6bUGad6cKg6Ls0e+1xXendWuhw7Sv+Kk8BOYCbL1XuxoFrz8QU7ZEP2AEWvWz5jvr3p39TV5d9VClTip76NtdUG5oy+InJh2sA4PbcNyJ/C+rCyJIprHk+fVsb/VN6/IljjP+c0PXBHjQVnM00kdoRcdPzA/8He/hPV2WbpYd+luELMk=----ATTACHMENT:----NDc2OTQ2NTg4NTgyMjEwNSAzMjA5ODQ3Njc2OTk2ODQyIDkwOTEyMzIwNDQ5NTQ5NjY=