Skip to content
PHP Ecosystem
Explore

HasContent

API reference › HTML Mixin › HasContent

traitUIAwesome\Html\Mixin\HasContent
Sourcesrc/HasContent.php
Used by 2 types

Provides an immutable API for managing element content.

PropertyTypeDescriptionDefined by
$content protectedstringContent string assigned to the element. Default: ''.HasContent
MethodDescriptionDefined by
clearContent()Clears encoded and raw content without changing other component state.HasContent
content()Appends encoded content.HasContent
getContent()Returns the content assigned to the element.HasContent
html()Appends trusted raw HTML content without encoding or sanitizing it.HasContent
public function clearContent(): static

Clears encoded and raw content without changing other component state.

Returns

static: New instance with empty content.

public function content(string|Stringable|UnitEnum ...$values): static

Appends encoded content.

Backed enums use their value (including 0); pure enums use their name. Values are normalized before encoding.

Parameters

ParameterTypeDescription
...$valuesstring|Stringable|UnitEnumContent to be encoded and appended.

Returns

static: New instance with appended encoded content.

public function getContent(): string

Returns the content assigned to the element.

Returns

string: Content value assigned to the element. Never null.

public function html(string|Stringable|UnitEnum ...$values): static

Appends trusted raw HTML content without encoding or sanitizing it.

Backed enums use their value (including 0); pure enums use their name.

Parameters

ParameterTypeDescription
...$valuesstring|Stringable|UnitEnumTrusted raw HTML content to be appended.

Returns

static: New instance with appended raw HTML content.