PromptBuilder::normalizePreferenceIdentifier( mixed $value, string $emptyMessage = 'Model preference identifiers cannot be empty.' ): string

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only by core. It is listed here for completeness.

Normalizes and validates a preference identifier string.

Parameters

$valuemixedrequired
The value to normalize.
$emptyMessagestringoptional
The message for empty or invalid values.

Default:'Model preference identifiers cannot be empty.'

Return

string The normalized identifier.

Source

private function normalizePreferenceIdentifier($value, string $emptyMessage = 'Model preference identifiers cannot be empty.'): string
{
    if (!is_string($value)) {
        throw new InvalidArgumentException($emptyMessage);
    }
    $trimmed = trim($value);
    if ($trimmed === '') {
        throw new InvalidArgumentException($emptyMessage);
    }
    return $trimmed;
}

Changelog

VersionDescription
0.2.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.