Class Inflector
Pluralize and singularize English words.
Inflector pluralizes and singularizes English nouns. Used by CakePHP's naming conventions throughout the framework.
Link: http://book.cakephp.org/3.0/en/core-libraries/inflector.html
Located at Utility/Inflector.php
Method Detail
_cachesource protected static
_cache( string $type , string $key , string|boolean $value false )
Cache inflected values, and return if already available
Parameters
- string
$type
- Inflection type
- string
$key
- Original value
- string|boolean
$value
optional false - Inflected value
Returns
string|boolean
Inflected value on cache hit or false on cache miss.
camelizesource public static
camelize( string $string , string $delimiter '_' )
Returns the input lower_case_delimited_string as a CamelCasedString.
Parameters
- string
$string
- String to camelize
- string
$delimiter
optional '_' - the delimiter in the input string
Returns
string
CamelizedStringLikeThis.
Link
http://book.cakephp.org/3.0/en/core-libraries/inflector.html#creating-camelcase-and-under-scored-formsclassifysource 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/3.0/en/core-libraries/inflector.html#creating-table-and-class-name-formsdasherizesource public static
dasherize( string $string )
Returns the input CamelCasedString as an dashed-string.
Also replaces underscores with dashes
Parameters
- string
$string
- The string to dasherize.
Returns
string
Dashed version of the input string
delimitsource public static
delimit( string $string , string $delimiter '_' )
Expects a CamelCasedInputString, and produces a lower_case_delimited_string
Parameters
- string
$string
- String to delimit
- string
$delimiter
optional '_' - the character to use as a delimiter
Returns
string
delimited string
humanizesource public static
humanize( string $string , string $delimiter '_' )
Returns the input lower_case_delimited_string as 'A Human Readable String'. (Underscores are replaced by spaces and capitalized following words.)
Parameters
- string
$string
- String to be humanized
- string
$delimiter
optional '_' - the character to replace with a space
Returns
string
Human-readable string
Link
http://book.cakephp.org/3.0/en/core-libraries/inflector.html#creating-human-readable-formspluralizesource 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/3.0/en/core-libraries/inflector.html#creating-plural-singular-formsresetsource 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', 'uninflected', 'irregular' or 'transliteration' $type.
Usage:
Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']); Inflector::rules('irregular', ['red' => 'redlings']); Inflector::rules('uninflected', ['dontinflectme']); Inflector::rules('transliteration', ['/å/' => 'aa']);
Parameters
- string
$type
- The type of inflection, either 'plural', 'singular', 'uninflected' 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/3.0/en/core-libraries/inflector.html#creating-plural-singular-formsslugsource public static
slug( string $string , string $replacement '-' )
Returns a string with all spaces converted to dashes (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/3.0/en/core-libraries/inflector.html#creating-url-safe-stringstableizesource 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/3.0/en/core-libraries/inflector.html#creating-table-and-class-name-formsunderscoresource public static
underscore( string $string )
Returns the input CamelCasedString as an underscored_string.
Also replaces dashes with underscores
Parameters
- string
$string
- CamelCasedString to be "underscorized"
Returns
string
underscore_version of the input string
Link
http://book.cakephp.org/3.0/en/core-libraries/inflector.html#creating-camelcase-and-under-scored-formsvariablesource 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/3.0/en/core-libraries/inflector.html#creating-variable-namesProperties 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/3.1/class-Cake.Utility.Inflector.html