BasicAttributesTrait

BasicAttributesTrait

Basic HTML Attributes (id, class)

Methods

setID

Set the id attribute.

BasicAttributesTrait::setID( string $id = '' ): self

Returns Self: This method can be chained.


getID

Gets the id attribute.

BasicAttributesTrait::getID( ): string

Return Value: string


setTitle

Set the title attribute.

BasicAttributesTrait::setTitle( string $title = '' ): self

Returns Self: This method can be chained.


getTitle

Gets the title attribute.

BasicAttributesTrait::getTitle( ): string

Return Value: string


setClass

Set the class attribute. Replaces any existing classes.

BasicAttributesTrait::setClass( string $class = '' ): self

Returns Self: This method can be chained.


addClass

Add a class to the element’s class atrribute.

BasicAttributesTrait::addClass( string $class = '' )

removeClass

Remove a class from the element’s class atrribute.

BasicAttributesTrait::removeClass( string $class = '' )

getClass

Gets the class attribute.

BasicAttributesTrait::getClass( ): string

Return Value: string


addData

Set a data-* attribute for passing values to scripts.

BasicAttributesTrait::addData( string $name, mixed $data = '', $encode = false ): self

Returns Self: This method can be chained.


getData

Gets a data-* attribute value by name.

BasicAttributesTrait::getData( $name, $decode = false ): string

Return Value: string $name


getAttributeString

Flattens an array of $name => $value pairs into an HTML attribues string name=“value”. Omits empty values and handles booleans.

BasicAttributesTrait::getAttributeString( array|boolean $filter = false ): string

Return Value: string