Skip to content
PHP Ecosystem
Explore

BaseAttributes

API reference › HTML Helper › Base › BaseAttributes

abstract classUIAwesome\Html\Helper\Base\BaseAttributes
Sourcesrc/Base/BaseAttributes.php
1 subclass

Provides reusable normalization and rendering for HTML attribute arrays.

MethodDescriptionDefined by
normalizeAttributes() staticNormalizes an array of HTML attributes into a flat associative array with processed values.BaseAttributes
render() staticRenders an array of HTML attributes into a string.BaseAttributes
public static function normalizeAttributes(mixed[] $attributes, bool $encode = true): array<string, bool|string>

Normalizes an array of HTML attributes into a flat associative array with processed values.

Returns a normalized array instead of an HTML string.

Parameters

ParameterTypeDescription
$attributesmixed[]Associative array of attribute names and values.
$encodeboolWhether to HTML-encode string values.

Returns

array<string, bool|string>: Flat associative array with normalized values. Boolean attributes may return true.

public static function render(mixed[] $attributes): string

Renders an array of HTML attributes into a string.

Validates names, normalizes values, and returns attributes in a stable order.

Parameters

ParameterTypeDescription
$attributesmixed[]Associative array of attribute names and values.

Returns

string: Rendered HTML attributes string.