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.'
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
| Version | Description |
|---|---|
| 0.2.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.