Skip to main content

HtmlClassAttributeSet

Class for storing and processing HTML class attribute.


  • Full name: \TwbsHelper\View\HtmlClassAttributeSet
  • Parent class: ArrayObject
  • This class implements: Stringable

Constants

ConstantVisibilityTypeValue
ATTRIBUTE_NAMEpublic'class'

Methods

__construct

Constructor.

public __construct(string|iterable<string> $classes = []): mixed

Parameters:

ParameterTypeDescription
$classesstring|iterable<string>
If a string is provided, it should be a space-separated list of classes (e.g., "class1 class2 class3").
If an iterable is provided, it should contain class names.

merge

Merge attributes with existing attributes.

public merge(iterable<string> $classes): self

Parameters:

ParameterTypeDescription
$classesiterable<string>

remove

public remove(string $classToRemove): ?string

Parameters:

ParameterTypeDescription
$classToRemovestring

__toString

Return a string of tag attributes.

public __toString(): string

cleanAttribute

public cleanAttribute(): self