MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / snake_to_camel

Function snake_to_camel

src/code_actions/extract_variable.rs:512–527  ·  view source on GitHub ↗

Convert `snake_case` to `camelCase`.

(s: &str)

Source from the content-addressed store, hash-verified

510
511/// Convert `snake_case` to `camelCase`.
512fn snake_to_camel(s: &str) -> String {
513 let parts: Vec<&str> = s.split('_').filter(|p| !p.is_empty()).collect();
514 if parts.is_empty() {
515 return "variable".to_string();
516 }
517
518 let mut result = parts[0].to_lowercase();
519 for part in &parts[1..] {
520 let mut chars = part.chars();
521 if let Some(first) = chars.next() {
522 result.extend(first.to_uppercase());
523 result.push_str(&chars.as_str().to_lowercase());
524 }
525 }
526 result
527}
528
529/// Deduplicate a variable name against existing variables in scope.
530///

Callers 2

to_camel_caseFunction · 0.70

Calls 5

filterMethod · 0.80
nextMethod · 0.80
extendMethod · 0.80
as_strMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected