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

Function to_camel_case

src/code_actions/extract_variable.rs:493–509  ·  view source on GitHub ↗

Convert a string to camelCase, starting with a lowercase letter.

(s: &str)

Source from the content-addressed store, hash-verified

491
492/// Convert a string to camelCase, starting with a lowercase letter.
493fn to_camel_case(s: &str) -> String {
494 if s.is_empty() {
495 return "variable".to_string();
496 }
497
498 // If it contains underscores, treat as snake_case
499 if s.contains('_') {
500 return snake_to_camel(s);
501 }
502
503 // Just lowercase the first character
504 let mut chars = s.chars();
505 let first = chars.next().unwrap();
506 let mut result = first.to_lowercase().to_string();
507 result.extend(chars);
508 result
509}
510
511/// Convert `snake_case` to `camelCase`.
512fn snake_to_camel(s: &str) -> String {

Callers 3

extract_method_call_nameFunction · 0.85
extract_property_nameFunction · 0.85
extract_static_call_nameFunction · 0.85

Calls 6

containsMethod · 0.80
nextMethod · 0.80
extendMethod · 0.80
snake_to_camelFunction · 0.70
is_emptyMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected