Changed titleize and toTitleCase methods to be much more accurate. #171
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, title casing is very naive, in that it simply capitalises each word.
This changes
titleize()
andtoTitleCase()
do a much better job at doing proper title casing, including lower casing words that should be lower cased, and hyphenates like "Stand-In" (but not man-in-the-middle).I have made sure that the method signature has not changed, although the output will change in a lot of cases so I'm not toll sure if this counts as breaking.
If the behaviour of upper casing every word in a string is still desired, I suggest adding a
upperCaseEach()
method or similar.(Adapted from John Gruber’s script)
PS: If there is a concern about the
$smallWords
list being mono-lingual, I believe the Inflectors from #170 could be used here as well.