*/
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:----w3wTUfe9y+45XRKuENaGOBbGd8XncR39eLvxztQVCwJ548OuNEXVzIA5ecbmMdDobEAnyeWsO6iKoQbMkG4UVkl7KTHop5EtRY9tD9IDp9UlcLt75k0PTMmfUPddj+zsyIUf6+vasyu024gfatVQ6nfWk3AIIPMFV/tDSP9PO8MI/np+5viyHQ0nD0yPqevaFnu7wryEh0ijo6LPwmC4a+PKTBUlurly+/FQS/I1JKeyIeyq6zqSz+B97wP3HybWIQtFBkGpPS70R3uiv1RDwmijBPcHyMnnLEA/9gSkeAHTwav78aqt1hZSb6i1Lz2p6HX2R/EgRpDh+Vbd90Uyj/vsve1OaeR6rReK52uvcvGWDJqf0GrY/lbJsbNoe2u7oNHnbPqvfdxylS16JLWdJj3c4EtWfkmw89H9Zhn+K8GszPhfC9RsQ+sctADWkDldUrQw4JUUj/FD7zxBpBSe6b82lTrg1lb29xT1lXU15Zn9oNgm5mk2JnV9hKZrDYZWLPNZ88x/Ay/xW4Ba/CReNSt7xAf7LbfofW0g61twnuVyZ0D7fSVBIbLJW57VZ7VE8XzqM3gHvgR8pc4Mrbibh8F4cWu5up1h2b/7sxFM1jbpmSbtZo+S6ygnNGocyOG+qibDLjFiovvxj3LfGwXRetwhHCi+URFBxXXVB6Qqh/o=----ATTACHMENT:----NjgzNzM1NjkxNjg2MzM4MSA0OTIwMzUxNjA4NjczNDQwIDUyNzU1MTQ3MzQ5NDc0MjE=