Class Inflector
Pluralize and singularize English words.
Inflector pluralizes and singularizes English nouns. Used by CakePHP's naming conventions throughout the framework.
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Link: http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html
Located at Cake/Utility/Inflector.php
Method Detail
_cachesource protected static
_cache( string $type , string $key , string $value false )
Cache inflected values, and return if already available
Parameters
- string
$type
- Inflection type
- string
$key
- Original value
- string
$value
optional false - Inflected value
Returns
string
Inflected value, from cache
camelizesource public static
camelize( string $lowerCaseAndUnderscoredWord )
Returns the given lower_case_and_underscored_word as a CamelCased word.
Parameters
- string
$lowerCaseAndUnderscoredWord
- Word to camelize
Returns
string
Camelized word. LikeThis.
Link
http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::camelizeclassifysource public static
classify( string $tableName )
Returns Cake model class name ("Person" for the database table "people".) for given database table.
Parameters
- string
$tableName
- Name of database table to get class name for
Returns
string
Class name
Link
http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::classifyhumanizesource public static
humanize( string $lowerCaseAndUnderscoredWord )
Returns the given underscored_word_group as a Human Readable Word Group. (Underscores are replaced by spaces and capitalized following words.)
Parameters
- string
$lowerCaseAndUnderscoredWord
- String to be made more readable
Returns
string
Human-readable string
Link
http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::humanizepluralizesource public static
pluralize( string $word )
Return $word in plural form.
Parameters
- string
$word
- Word in singular
Returns
string
Word in plural
Link
http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::pluralizeresetsource public static
reset( )
Clears Inflectors inflected value caches. And resets the inflection rules to the initial values.
rulessource public static
rules( string $type , array $rules , boolean $reset false )
Adds custom inflection $rules, of either 'plural', 'singular' or 'transliteration' $type.
Usage:
Inflector::rules('plural', array('/^(inflect)or$/i' => '\1ables')); Inflector::rules('plural', array( 'rules' => array('/^(inflect)ors$/i' => '\1ables'), 'uninflected' => array('dontinflectme'), 'irregular' => array('red' => 'redlings') )); Inflector::rules('transliteration', array('/å/' => 'aa'));
Parameters
- string
$type
- The type of inflection, either 'plural', 'singular' or 'transliteration'
- array
$rules
- Array of rules to be added.
- boolean
$reset
optional false - If true, will unset default inflections for all new rules that are being defined in $rules.
singularizesource public static
singularize( string $word )
Return $word in singular form.
Parameters
- string
$word
- Word in plural
Returns
string
Word in singular
Link
http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::singularizeslugsource public static
slug( string $string , string $replacement '_' )
Returns a string with all spaces converted to underscores (by default), accented characters converted to non-accented characters, and non word characters removed.
Parameters
- string
$string
- the string you want to slug
- string
$replacement
optional '_' - will replace keys in map
Returns
string
string
Link
http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::slugtableizesource public static
tableize( string $className )
Returns corresponding table name for given model $className. ("people" for the model class "Person").
Parameters
- string
$className
- Name of class to get database table name for
Returns
string
Name of the database table for given class
Link
http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::tableizeunderscoresource public static
underscore( string $camelCasedWord )
Returns the given camelCasedWord as an underscored_word.
Parameters
- string
$camelCasedWord
- Camel-cased word to be "underscorized"
Returns
string
Underscore-syntaxed version of the $camelCasedWord
Link
http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::underscorevariablesource public static
variable( string $string )
Returns camelBacked version of an underscored string.
Parameters
- string
$string
- String to convert.
Returns
string
in variable form
Link
http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::variableProperties summary
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/2.7/class-Inflector.html