3 ? '...' : ''); } public static function sanitize(string $value): string { $decoded = html_entity_decode(strip_tags($value), ENT_QUOTES | ENT_HTML5, 'UTF-8'); $whitelisted = preg_replace('/[^\p{L}\p{N}\s.,()_№+-]/u', '', $decoded) ?? ''; $collapsed = preg_replace('/\s+/u', ' ', $whitelisted) ?? $whitelisted; return trim($collapsed); } }