Inflector Class Info:
- Class Declaration:
class Inflector
- File name:
- cake/libs/inflector.php
- Description:
Pluralize and singularize English words.
Inflector pluralizes and singularizes English nouns. Used by Cake's naming conventions throughout the framework.
- Package
- cake
- Subpackage
- cake.cake.libs
- Link
- http://book.cakephp.org/view/1478/Inflector
Properties:
-
_camelize array
Cached Camelize Inflections
-
_classify array
Classify cached inflecctions
-
_humanize array
Humanize cached inflections
-
_plural array
Plural inflector rules
-
_pluralized array
Cached array identity map of pluralized words.
-
_singular array
Singular inflector rules
-
_singularized array
Cached array identity map of singularized words.
-
_tableize array
Tablize cached inflections
-
_transliteration array
Default map of accented and special characters to ASCII characters
-
_underscore array
Cached Underscore Inflections
-
_uninflected array
Words that should not be inflected
Method Summary:
- _cache( $type, $key, $value = false )
- camelize( $lowerCaseAndUnderscoredWord )
- classify( $tableName )
- getInstance( )
- humanize( $lowerCaseAndUnderscoredWord )
- pluralize( $word )
- rules( $type, $rules, $reset = false )
- singularize( $word )
- slug( $string, $replacement = '_', $map = array ( ) )
- tableize( $className )
- underscore( $camelCasedWord )
- variable( $string )
_cache
topCache inflected values, and return if already available
- Parameters:
-
-
string $type required
Inflection type
-
string $key required
Original value
-
string $value optional false
Inflected value
-
- Method defined in:
- cake/libs/inflector.php on line 314
- Return
string Inflected value, from cache
- Access
protected
camelize
topReturns the given lower_case_and_underscored_word as a CamelCased word.
- Parameters:
-
-
$lowerCaseAndUnderscoredWord required
-
- Method defined in:
- cake/libs/inflector.php on line 493
- Return
string Camelized word. LikeThis.
- Access
public
- Static
- Link
- http://book.cakephp.org/view/1479/Class-methods
classify
topReturns Cake model class name ("Person" for the database table "people".) for given database table.
- Parameters:
-
-
string $tableName required
Name of database table to get class name for
-
- Method defined in:
- cake/libs/inflector.php on line 566
- Return
string Class name
- Access
public
- Static
- Link
- http://book.cakephp.org/view/1479/Class-methods
getInstance
topGets a reference to the Inflector object instance
- Method defined in:
- cake/libs/inflector.php on line 296
- Return
object
- Access
public
humanize
topReturns the given underscored_word_group as a Human Readable Word Group. (Underscores are replaced by spaces and capitalized following words.)
- Parameters:
-
-
$lowerCaseAndUnderscoredWord required
-
- Method defined in:
- cake/libs/inflector.php on line 530
- Return
string Human-readable string
- Access
public
- Static
- Link
- http://book.cakephp.org/view/1479/Class-methods
pluralize
topReturn $word in plural form.
- Parameters:
-
-
string $word required
Word in singular
-
- Method defined in:
- cake/libs/inflector.php on line 397
- Return
string Word in plural
- Access
public
- Static
- Link
- http://book.cakephp.org/view/1479/Class-methods
rules
topAdds 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 required
The type of inflection, either 'plural', 'singular' or 'transliteration'
-
array $rules required
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.
-
- Method defined in:
- cake/libs/inflector.php on line 351
- Access
public
- Return
void
- Static
singularize
topReturn $word in singular form.
- Parameters:
-
-
string $word required
Word in plural
-
- Method defined in:
- cake/libs/inflector.php on line 444
- Return
string Word in singular
- Access
public
- Static
- Link
- http://book.cakephp.org/view/1479/Class-methods
slug
topReturns 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 required
the string you want to slug
-
string $replacement optional '_'
will replace keys in map
-
array $map optional array ( )
extra elements to map to the replacement
-
- Method defined in:
- cake/libs/inflector.php on line 608
- Deprecated
$map param will be removed in future versions. Use Inflector::rules() instead
- Return
string
- Access
public
- Static
- Link
- http://book.cakephp.org/view/1479/Class-methods
tableize
topReturns corresponding table name for given model $className. ("people" for the model class "Person").
- Parameters:
-
-
string $className required
Name of class to get database table name for
-
- Method defined in:
- cake/libs/inflector.php on line 548
- Return
string Name of the database table for given class
- Access
public
- Static
- Link
- http://book.cakephp.org/view/1479/Class-methods
underscore
topReturns the given camelCasedWord as an underscored_word.
- Parameters:
-
-
string $camelCasedWord required
Camel-cased word to be "underscorized"
-
- Method defined in:
- cake/libs/inflector.php on line 511
- Return
string Underscore-syntaxed version of the $camelCasedWord
- Access
public
- Static
- Link
- http://book.cakephp.org/view/1479/Class-methods
variable
topReturns camelBacked version of an underscored string.
- Parameters:
-
-
string $string required
-
- Method defined in:
- cake/libs/inflector.php on line 584
- Return
string in variable form
- Access
public
- Static
- Link
- http://book.cakephp.org/view/1479/Class-methods