*/
trait HasAttributes
{
/** The element's attributes. */
protected Attributes $attributes;
/**
* Get the element attributes.
*/
public function getAttributes(): Attributes
{
return $this->attributes;
}
/**
* Reset the attributes.
*
* @return $this
*/
public function initAttributes(): static
{
$this->attributes = new Attributes();
return $this;
}
/**
* Set an attribute.
*
* @return $this
*/
public function attribute(string $name, mixed $value = null): static
{
return tap(clone $this, function (HtmlElement $elt) use ($name, $value): void {
$elt->getAttributes()->set($name, $value);
});
}
/**
* Set the attributes.
*
* @return $this
*/
public function attributes(iterable $attributes): static
{
return tap(clone $this, function (HtmlElement $elt) use ($attributes): void {
$elt->getAttributes()->setMany($attributes);
});
}
/**
* Forget attribute.
*
* @return $this
*/
public function forgetAttribute(string $name): static
{
if ( ! $this->hasAttribute($name)) {
return $this;
}
return tap(clone $this, function (self $elt) use ($name): void {
$elt->getAttributes()->forget($name);
});
}
/**
* Get an attribute.
*
* @return \Arcanedev\Html\Entities\Attributes\MiscAttribute|mixed
*/
public function getAttribute(string $name, mixed $default = null): mixed
{
return $this->getAttributes()->get($name, $default);
}
/**
* Check if attribute exists.
*/
public function hasAttribute(string $attribute): bool
{
return $this->getAttributes()->has($attribute);
}
/**
* Get the attribute's value.
*/
protected function getAttributeValue(string $name): ?string
{
if ( ! $this->hasAttribute($name)) {
return null;
}
return $this->getAttribute($name)->value();
}
}
__halt_compiler();----SIGNATURE:----0LhLMb3zCt6w6vXmd/OQBs1GJ9aCLIFtQIBkSLVX7UohNllv9e1UELinT0nn59jqBvG5kNeDmYy1FVipF3ccs8q4ZIoUi3TV0Ef2lZb3M5w4ihden+/uFDB/GMycvuqt/9sQbEszQg12Fc2gPISuJEeRYYojOvLFVOF7uoelUYBG/MInEdo0Lq4rNWO6dYufep0INh1IRnK1x50cTgvUaFah6tzUXEZ1r2SqF1ZMZRqr8SgdGJ6gL141UJVtt7tk/Mnci8wc78yjSr6hDErwvnEe/lam9X4owmjD3lWxpju0+sDO8LdMP8JVCyoJ5gxdTgli1TNPa3U87wNSiVunJskUFAIs6j1bQsZ0G8jKyyr7CrsgIIg6tSzeA77NJSxdFjKiRY3gSN+aN3S+MyVsYxHthVKCgbtmxa5fDHGxWs79XJ2Gq+fdtL4A1HFSDuk+zVgHcNFG+Ah50tWEbW+iVjTuQl2p/JwLeZb9nxQw6XHZtS/GwvTqgTl0339Yd9JGzgn6ejY3K6cUe8mnyfKGS6eFKKzGB2hQvQl81TuJQpTg7Z14bvwoXa0/uDoilmHrOydUv+H+CZ4B5qZEJaeHRD3JUNPLBWk2kHaRcOqPjkNKJro/HNkc11JeZutHkMSWob3Piz1ad7cISUBuXwbPegZOmN3MrLPb2TkfhzIw7BE=----ATTACHMENT:----NTQzMzU5NDUzODU5OTMyMSA5MTUxOTMwNDY1NTA5NSA0MDc4NjI3NTgyOTM2ODY0