We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 51a5e73 commit e739ec5Copy full SHA for e739ec5
src/helpers.php
@@ -227,11 +227,11 @@ function remove_suffix($needle, $haystack): string
227
function slug_to_title($slug, string $separator = '_'): string
228
{
229
return Str::of($slug)
230
- ->camel()
231
- ->snake($separator)
232
- ->replace($separator, ' ')
233
- ->title()
234
- ->toString();;
+ ->replaceMatches('/([a-z])([A-Z])/', '$1 $2') // Split camelCase: pEnding → p Ending
+ ->replace($separator, ' ') // Replace custom separator (e.g. _ or space) with space
+ ->lower() // Lowercase everything
+ ->title() // Capitalize words
+ ->toString();
235
}
236
237
0 commit comments