Utils: use match to clean up stringifyValueForTrace()

This commit is contained in:
Dylan K. Taylor 2022-05-10 14:04:52 +01:00
parent 81d8aed2e2
commit 17b0e0be84
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -438,19 +438,13 @@ final class Utils{
} }
private static function stringifyValueForTrace(mixed $value, int $maxStringLength) : string{ private static function stringifyValueForTrace(mixed $value, int $maxStringLength) : string{
if(is_object($value)){ return match(true){
return "object " . self::getNiceClassName($value) . "#" . spl_object_id($value); is_object($value) => "object " . self::getNiceClassName($value) . "#" . spl_object_id($value),
} is_array($value) => "array[" . count($value) . "]",
if(is_array($value)){ is_string($value) => "string[" . strlen($value) . "] " . substr(Utils::printable($value), 0, $maxStringLength),
return "array[" . count($value) . "]"; is_bool($value) => $value ? "true" : "false",
} default => gettype($value) . " " . Utils::printable((string) $value)
if(is_string($value)){ };
return "string[" . strlen($value) . "] " . substr(Utils::printable($value), 0, $maxStringLength);
}
if(is_bool($value)){
return $value ? "true" : "false";
}
return gettype($value) . " " . Utils::printable((string) $value);
} }
/** /**