Suggestion: Add a PascalCase setting for generated usernames.
Redtama opened this issue · 3 comments
I've looked around the documentation and tried a few things but couldn't seem to find a way to force generated usernames to use PascalCase.
For example, I was given the randomly generated username of Happybiographer
, but I would love this to instead be HappyBiographer
.
I appreciate that when it comes to converting usernames, you wouldn't really be able to convert to PascalCase successfully so perhaps it should just behave the same as 'mixed'
when converting. But certainly when generating a random adjective-noun username it would be great to be able have this feature.
Is this possible?
@Redtama when it converts the case it does use the Laravel string helper so you should be able to set the case to 'studly'
which I believe is the equivalent of pascal case.
As long as there is a space between the two words, using 'studly'
does convert correctly as 'HappyBiographer'
. However if it's passed as 'happybiographer'
then it will end up being 'Happybiographer'
For example
UsernameGenerator::setConfig(['case' => 'studly'])->generate('happy biographer');
// Returns 'HappyBiographer'
UsernameGenerator::setConfig(['case' => 'studly'])->generate('happybiographer');
// Returns 'Happybiographer'
UsernameGenerator::setConfig(['case' => 'studly'])->generate();
// Returns a random name with the correct casing like 'HappyBiographer'
@samueljtaylor That is super helpful thank you! I had never heard the term "studly" but after a bit of googling it does seem to be basically just another term for pascal case.
I've tried it and it works great 👍🏻.
"it does use the Laravel string helper" - it may help others if this was added to the documentation. If it already is and I just missed it then I apologise! Thanks again for your help and providing a great tool!
Okay perfect, glad to hear it! I've added it just recently to the readme but I'll make it a bit more clear.