UPDATE: I have renamed this class HGrammar to prevent any conflict.
This extension is a simple helper class which I use to make sure text generated by my application is natural.
Plurals - no need to put bracket(s) after your word(s). Lists - produce a nice, simple and clean list from an array. Vowels - Words beginning with a vowel are prefixed with a/an.
protected/components or I actually use protected/helpersExamples:
[php]
// PLURALS
echo HGrammar::plural($commentCount,'comment');
// Output: 'comment' if commentCount is 1, otherwise 'comments'
// LISTS
$people = array('John','Trevor','Qiang');
echo HGrammar::commaList($people);
// Output: 'John, Trevor and Qiang'.
See PHPDoc for Vowels function
Total 2 comments
This one is going to come in very handy!
Never a fan of adding an if block for (count == 1).
Leave a comment
Please login to leave your comment.