Skip to content
PHP Ecosystem
Explore

BaseEnum

API reference › HTML Helper › Base › BaseEnum

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

Provides reusable normalization helpers for enum and scalar values.

BackedEnum for enums with scalar values. UnitEnum for all enum types.

MethodDescriptionDefined by
normalizeArray() staticNormalizes an array of enum values or mixed values to their scalar values or names.BaseEnum
normalizeStringArray() staticNormalizes an array of enum values or mixed values to string representations.BaseEnum
normalizeStringValue() staticNormalizes a single enum value or mixed value to a string representation.BaseEnum
normalizeValue() staticNormalizes a single enum value to its scalar value or name.BaseEnum
public static function normalizeArray(mixed[] $values): mixed[]

Normalizes an array of enum values or mixed values to their scalar values or names.

Applies normalizeValue() to each element.

Parameters

ParameterTypeDescription
$valuesmixed[]Array of enum instances or mixed values to normalize.

Returns

mixed[]: Array of normalized scalar values, names, or original values for non-enums. normalizeValue() for single value normalization.

Throws

public static function normalizeStringArray(mixed[] $values): string[]

Normalizes an array of enum values or mixed values to string representations.

Applies normalizeStringValue() to each element.

Parameters

ParameterTypeDescription
$valuesmixed[]Array of enum instances or mixed values to normalize.

Returns

string[]: Array of normalized string representations. normalizeStringValue() for single value string normalization.

Throws

public static function normalizeStringValue(mixed $value): string

Normalizes a single enum value or mixed value to a string representation.

Converts null to null, booleans to true or false, and arrays to Array for deterministic textual output.

Parameters

ParameterTypeDescription
$valuemixedValue to normalize.

Returns

string: Normalized string representation. normalizeStringArray() for batch string normalization.

Throws

public static function normalizeValue(mixed $value): ($value is UnitEnum ? int|string : ($value is string ? string : bool|float|int|mixed[]|null))

Normalizes a single enum value to its scalar value or name.

Returns the original value unchanged for non-enum input.

Parameters

ParameterTypeDescription
$valuemixedValue to normalize.

Returns

($value is UnitEnum ? int|string : ($value is string ? string : bool|float|int|mixed[]|null)): Scalar value for BackedEnum, name for pure enums, or the original value for non-enums. normalizeArray() for batch normalization.

Throws