-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for different character separators #45
Comments
@drgomesp at the moment we have this feature, but I guess we can easly improve Humanize class to support mulitiple separators and also forbiden words. Now there is only one forbidden word, |
@norzechowicz I made a small proof of concept of what it would look like to support multiple character separators. Humanize.php public function __toString()
{
$humanized = trim(strtolower(preg_replace(array('/([A-Z])/', "/[{$this->separator}\\s]+/"), array('_$1', ' '), $this->text)));
$humanized = trim(str_replace($this->forbiddenWords, "", $humanized));
return $this->capitalize ? ucfirst($humanized) : $humanized;
} And the String.php public static function humanize($text, $capitalize = true, $separator = Humanize::SEPARATOR_UNDERSCORE)
{
return (string) new Humanize($text, $capitalize, $separator);
} What do you think? Shall I open a PR? |
@drgomesp yes, PR are more than welcome :P |
@norzechowicz done. Closing this one :) |
Currently if I do this:
I get
Land-Rover
.Is there any way to support setting a special character modified so that it doesn't always couple to the underscore character?
The text was updated successfully, but these errors were encountered: