*/
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:----uW3ZwmxQG1NAl8yUdgsDwqHCm+Pe33p7t/ODQWCXL0qrNWDWxfPXArxhMV1lkTbWVWcddDfj8PCDmrE9/Z5E9Z91w+c0VmfUxMp2wGgSd9e/5DhWEG8hsIQoTD6rIH05Rh+9zlnWaA6rejmkta+5NpRQ8GaFxhPRXy3/UoLTj/iNKp/D2hJiLTdB6KsOEIQcRZ3/yRoJEnDhAFqCtT5dEpGDbroozhTtZ+Yz0+Xb/3BoCXPTCv6x+TvsBl8WSaKpUNAFE6+d7oJ9XmEIIz4mOyP4eVOrhmVZdirHDLsGee0a28utfNq/SB6XecEnHvNxtFNca74UHXrg3PP2CsEZzRrn8EBDc7sEaUMv3MskAAOFsoRNeI29OPp8d5a6nSN5hFq8tEM6hc7CfK3DVvPOgva5RDc3gqWfk6FnCQyuQfH3k50w/KdwG9snKvux5EF8uwN1nLWE6fnXxoT1Cz+AgMjF6cIlVlbCxogoI53lAUt5FVI226wlMp0By0q5bVdYLlhB5QNzVUQP+XU9TQZWf9JpfEsqL95BVGSFxlkpbWJgkYtnYLvppqCUXE51qDZwjGa0n3dbWeYMTaQ/2kXgSYayGYS506ZZP6tbhpvDgmXXhPG0wlNYtS5T/3JEoIaAkHUYKT6QUsUzC5P9MkUtmlixQKEqmfzsUjQCWQVd2pY=----ATTACHMENT:----MTY4NzkxMjY3MTkxNjIwIDM1NTU4NDQyOTY2Mzg2NzEgNTc2ODQ1NjIxMzk3NjU2MA==