wip
This commit is contained in:
@@ -59,11 +59,20 @@ function module_exists(string $moduleName): bool
|
||||
*/
|
||||
function string(mixed $value): string
|
||||
{
|
||||
if (! is_string($value)) {
|
||||
throw new Exception('!!!Make it string!!!');
|
||||
if (is_string($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
if ($value instanceof Stringable) {
|
||||
return (string) $value;
|
||||
}
|
||||
|
||||
// Optionally handle scalar values (int, float, bool) as strings too
|
||||
if (is_scalar($value)) {
|
||||
return (string) $value;
|
||||
}
|
||||
|
||||
throw new Exception('Value is not stringable.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user