Bladeren bron

修复:下划线转驼峰方法强制小写问题

萤火科技 2 jaren geleden
bovenliggende
commit
658125cdc6
1 gewijzigde bestanden met toevoegingen van 5 en 4 verwijderingen
  1. 5 4
      app/common.php

+ 5 - 4
app/common.php

@@ -76,14 +76,15 @@ function throwError(string $message, ?int $status = null, array $data = [])
 
 /**
  * 下划线转驼峰
- * @param string $uncamelized_words
+ * @param string $str
  * @param string $separator
  * @return string
  */
-function camelize(string $uncamelized_words, string $separator = '_'): string
+function camelize(string $str, string $separator = '_'): string
 {
-    $uncamelized_words = $separator . str_replace($separator, " ", strtolower($uncamelized_words));
-    return ltrim(str_replace(" ", "", ucwords($uncamelized_words)), $separator);
+    $str = ucwords(str_replace($separator, ' ', $str));
+    $str = str_replace(' ', '', $str);
+    return lcfirst($str);
 }
 
 /**