This is documentation for Kohana v2.3.x.
Status | Draft |
---|---|
Todo | Proof read |
Provides methods for working with the pluralization and singularization of words as well as other methods to work with phrases.
uncountable($string)
checks whether the given string is an uncountable word. Returns TRUE or FALSE. This method uses a words list from the inflector.php file, located into the system/config folder
inflector::uncountable('money'); //returns TRUE inflector::uncountable('book'); //returns FALSE
singular($str, $count = NULL)
will attempt to singularize the given string. Returns the string. If a string is uncountable it will return the string without modification.
Note: this function works for English words only.
inflector::singular('books'); //returns 'book' inflector::singular('books',0); //returns 'books'
plural($str, $count = NULL)
will attempt to pluralize the given string. Returns the string. If a string is uncountable it will return the string without modification.
Note: this function works for English words only.
inflector::plural('book'); //returns 'books' inflector::plural('book',1); //returns 'book'
camelize($str)
will attempt to camelize the given string. Returns the string.
inflector::camelize('system_initialization'); //returns 'systemInitialization' inflector::camelize('system initialization'); //returns 'systemInitialization'
underscore($str)
makes a phrase underscored instead of spaced. Returns the string.
inflector::underscore('Underscores a phrase.'); //returns Underscores_a_phrase.'
humanize($str)
makes a phrase human-readable instead of dashed or underscored. Returns the string.
inflector::humanize('Remove_underscores_from_a_phrase.'); //returns 'Remove underscores from a phrase.' inflector::humanize('Remove-dashes-from-a-phrase.'); //returns 'Remove dashes from a phrase.'