Pluralize and singularize English words.
Inflector pluralizes and singularizes English nouns. Used by CakePHP's naming conventions throughout the framework.
arrayarrayarrayarrayarrayarrayarrayReturns the input lower_case_delimited_string as 'A Human Readable String'. (Underscores are replaced by spaces and capitalized following words.)
Clears Inflectors inflected value caches. And resets the inflection rules to the initial values.
Adds custom inflection $rules, of either 'plural', 'singular', 'uninflected', 'irregular' or 'transliteration' $type.
Returns a string with all spaces converted to dashes (by default), accented characters converted to non-accented characters, and non word characters removed.
_cache( string $type , string $key , string|boolean $value false )
Cache inflected values, and return if already available
$type $key $value optional false camelize( string $string , string $delimiter '_' )
Returns the input lower_case_delimited_string as a CamelCasedString.
$string $delimiter optional '_' classify( string $tableName )
Returns Cake model class name ("Person" for the database table "people".) for given database table.
$tableName dasherize( string $string )
Returns the input CamelCasedString as an dashed-string.
Also replaces underscores with dashes
$string delimit( string $string , string $delimiter '_' )
Expects a CamelCasedInputString, and produces a lower_case_delimited_string
$string $delimiter optional '_' 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.)
$string $delimiter optional '_' pluralize( string $word )
Return $word in plural form.
$word reset( )
Clears Inflectors inflected value caches. And resets the inflection rules to the initial values.
rules( string $type , array $rules , boolean $reset false )
Adds custom inflection $rules, of either 'plural', 'singular', 'uninflected', 'irregular' or 'transliteration' $type.
Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']);
Inflector::rules('irregular', ['red' => 'redlings']);
Inflector::rules('uninflected', ['dontinflectme']);
Inflector::rules('transliteration', ['/å/' => 'aa']); $type The type of inflection, either 'plural', 'singular', 'uninflected' or 'transliteration'.
$rules $reset optional false If true, will unset default inflections for all new rules that are being defined in $rules.
singularize( string $word )
Return $word in singular form.
$word 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.
$string $replacement optional '-' tableize( string $className )
Returns corresponding table name for given model $className. ("people" for the model class "Person").
$className underscore( string $string )
Returns the input CamelCasedString as an underscored_string.
Also replaces dashes with underscores
$string variable( string $string )
Returns camelBacked version of an underscored string.
$string protected static array
Irregular rules
[
'atlas' => 'atlases',
'beef' => 'beefs',
'brief' => 'briefs',
'brother' => 'brothers',
'cafe' => 'cafes',
'child' => 'children',
'cookie' => 'cookies',
'corpus' => 'corpuses',
'cow' => 'cows',
'criterion' => 'criteria',
'ganglion' => 'ganglions',
'genie' => 'genies',
'genus' => 'genera',
'graffito' => 'graffiti',
'hoof' => 'hoofs',
'loaf' => 'loaves',
'man' => 'men',
'money' => 'monies',
'mongoose' => 'mongooses',
'move' => 'moves',
'mythos' => 'mythoi',
'niche' => 'niches',
'numen' => 'numina',
'occiput' => 'occiputs',
'octopus' => 'octopuses',
'opus' => 'opuses',
'ox' => 'oxen',
'penis' => 'penises',
'person' => 'people',
'sex' => 'sexes',
'soliloquy' => 'soliloquies',
'testis' => 'testes',
'trilby' => 'trilbys',
'turf' => 'turfs',
'potato' => 'potatoes',
'hero' => 'heroes',
'tooth' => 'teeth',
'goose' => 'geese',
'foot' => 'feet',
'foe' => 'foes',
'sieve' => 'sieves'
] protected static array
Plural inflector rules
[
'/(s)tatus$/i' => '\1tatuses',
'/(quiz)$/i' => '\1zes',
'/^(ox)$/i' => '\1\2en',
'/([m|l])ouse$/i' => '\1ice',
'/(matr|vert|ind)(ix|ex)$/i' => '\1ices',
'/(x|ch|ss|sh)$/i' => '\1es',
'/([^aeiouy]|qu)y$/i' => '\1ies',
'/(hive)$/i' => '\1s',
'/(chef)$/i' => '\1s',
'/(?:([^f])fe|([lre])f)$/i' => '\1\2ves',
'/sis$/i' => 'ses',
'/([ti])um$/i' => '\1a',
'/(p)erson$/i' => '\1eople',
'/(?<!u)(m)an$/i' => '\1en',
'/(c)hild$/i' => '\1hildren',
'/(buffal|tomat)o$/i' => '\1\2oes',
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin)us$/i' => '\1i',
'/us$/i' => 'uses',
'/(alias)$/i' => '\1es',
'/(ax|cris|test)is$/i' => '\1es',
'/s$/' => 's',
'/^$/' => '',
'/$/' => 's',
] protected static array
Singular inflector rules
[
'/(s)tatuses$/i' => '\1\2tatus',
'/^(.*)(menu)s$/i' => '\1\2',
'/(quiz)zes$/i' => '\\1',
'/(matr)ices$/i' => '\1ix',
'/(vert|ind)ices$/i' => '\1ex',
'/^(ox)en/i' => '\1',
'/(alias)(es)*$/i' => '\1',
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us',
'/([ftw]ax)es/i' => '\1',
'/(cris|ax|test)es$/i' => '\1is',
'/(shoe)s$/i' => '\1',
'/(o)es$/i' => '\1',
'/ouses$/' => 'ouse',
'/([^a])uses$/' => '\1us',
'/([m|l])ice$/i' => '\1ouse',
'/(x|ch|ss|sh)es$/i' => '\1',
'/(m)ovies$/i' => '\1\2ovie',
'/(s)eries$/i' => '\1\2eries',
'/([^aeiouy]|qu)ies$/i' => '\1y',
'/(tive)s$/i' => '\1',
'/(hive)s$/i' => '\1',
'/(drive)s$/i' => '\1',
'/([le])ves$/i' => '\1f',
'/([^rfoa])ves$/i' => '\1fe',
'/(^analy)ses$/i' => '\1sis',
'/(analy|diagno|^ba|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
'/([ti])a$/i' => '\1um',
'/(p)eople$/i' => '\1\2erson',
'/(m)en$/i' => '\1an',
'/(c)hildren$/i' => '\1\2hild',
'/(n)ews$/i' => '\1\2ews',
'/eaus$/' => 'eau',
'/^(.*us)$/' => '\\1',
'/s$/i' => ''
] protected static array
Default map of accented and special characters to ASCII characters
[
'ä' => 'ae',
'æ' => 'ae',
'ǽ' => 'ae',
'ö' => 'oe',
'œ' => 'oe',
'ü' => 'ue',
'Ä' => 'Ae',
'Ü' => 'Ue',
'Ö' => 'Oe',
'À' => 'A',
'Á' => 'A',
'Â' => 'A',
'Ã' => 'A',
'Å' => 'A',
'Ǻ' => 'A',
'Ā' => 'A',
'Ă' => 'A',
'Ą' => 'A',
'Ǎ' => 'A',
'à' => 'a',
'á' => 'a',
'â' => 'a',
'ã' => 'a',
'å' => 'a',
'ǻ' => 'a',
'ā' => 'a',
'ă' => 'a',
'ą' => 'a',
'ǎ' => 'a',
'ª' => 'a',
'Ç' => 'C',
'Ć' => 'C',
'Ĉ' => 'C',
'Ċ' => 'C',
'Č' => 'C',
'ç' => 'c',
'ć' => 'c',
'ĉ' => 'c',
'ċ' => 'c',
'č' => 'c',
'Ð' => 'D',
'Ď' => 'D',
'Đ' => 'D',
'ð' => 'd',
'ď' => 'd',
'đ' => 'd',
'È' => 'E',
'É' => 'E',
'Ê' => 'E',
'Ë' => 'E',
'Ē' => 'E',
'Ĕ' => 'E',
'Ė' => 'E',
'Ę' => 'E',
'Ě' => 'E',
'è' => 'e',
'é' => 'e',
'ê' => 'e',
'ë' => 'e',
'ē' => 'e',
'ĕ' => 'e',
'ė' => 'e',
'ę' => 'e',
'ě' => 'e',
'Ĝ' => 'G',
'Ğ' => 'G',
'Ġ' => 'G',
'Ģ' => 'G',
'Ґ' => 'G',
'ĝ' => 'g',
'ğ' => 'g',
'ġ' => 'g',
'ģ' => 'g',
'ґ' => 'g',
'Ĥ' => 'H',
'Ħ' => 'H',
'ĥ' => 'h',
'ħ' => 'h',
'І' => 'I',
'Ì' => 'I',
'Í' => 'I',
'Î' => 'I',
'Ї' => 'Yi',
'Ï' => 'I',
'Ĩ' => 'I',
'Ī' => 'I',
'Ĭ' => 'I',
'Ǐ' => 'I',
'Į' => 'I',
'İ' => 'I',
'і' => 'i',
'ì' => 'i',
'í' => 'i',
'î' => 'i',
'ï' => 'i',
'ї' => 'yi',
'ĩ' => 'i',
'ī' => 'i',
'ĭ' => 'i',
'ǐ' => 'i',
'į' => 'i',
'ı' => 'i',
'Ĵ' => 'J',
'ĵ' => 'j',
'Ķ' => 'K',
'ķ' => 'k',
'Ĺ' => 'L',
'Ļ' => 'L',
'Ľ' => 'L',
'Ŀ' => 'L',
'Ł' => 'L',
'ĺ' => 'l',
'ļ' => 'l',
'ľ' => 'l',
'ŀ' => 'l',
'ł' => 'l',
'Ñ' => 'N',
'Ń' => 'N',
'Ņ' => 'N',
'Ň' => 'N',
'ñ' => 'n',
'ń' => 'n',
'ņ' => 'n',
'ň' => 'n',
'ʼn' => 'n',
'Ò' => 'O',
'Ó' => 'O',
'Ô' => 'O',
'Õ' => 'O',
'Ō' => 'O',
'Ŏ' => 'O',
'Ǒ' => 'O',
'Ő' => 'O',
'Ơ' => 'O',
'Ø' => 'O',
'Ǿ' => 'O',
'ò' => 'o',
'ó' => 'o',
'ô' => 'o',
'õ' => 'o',
'ō' => 'o',
'ŏ' => 'o',
'ǒ' => 'o',
'ő' => 'o',
'ơ' => 'o',
'ø' => 'o',
'ǿ' => 'o',
'º' => 'o',
'Ŕ' => 'R',
'Ŗ' => 'R',
'Ř' => 'R',
'ŕ' => 'r',
'ŗ' => 'r',
'ř' => 'r',
'Ś' => 'S',
'Ŝ' => 'S',
'Ş' => 'S',
'Ș' => 'S',
'Š' => 'S',
'ẞ' => 'SS',
'ś' => 's',
'ŝ' => 's',
'ş' => 's',
'ș' => 's',
'š' => 's',
'ſ' => 's',
'Ţ' => 'T',
'Ț' => 'T',
'Ť' => 'T',
'Ŧ' => 'T',
'ţ' => 't',
'ț' => 't',
'ť' => 't',
'ŧ' => 't',
'Ù' => 'U',
'Ú' => 'U',
'Û' => 'U',
'Ũ' => 'U',
'Ū' => 'U',
'Ŭ' => 'U',
'Ů' => 'U',
'Ű' => 'U',
'Ų' => 'U',
'Ư' => 'U',
'Ǔ' => 'U',
'Ǖ' => 'U',
'Ǘ' => 'U',
'Ǚ' => 'U',
'Ǜ' => 'U',
'ù' => 'u',
'ú' => 'u',
'û' => 'u',
'ũ' => 'u',
'ū' => 'u',
'ŭ' => 'u',
'ů' => 'u',
'ű' => 'u',
'ų' => 'u',
'ư' => 'u',
'ǔ' => 'u',
'ǖ' => 'u',
'ǘ' => 'u',
'ǚ' => 'u',
'ǜ' => 'u',
'Ý' => 'Y',
'Ÿ' => 'Y',
'Ŷ' => 'Y',
'ý' => 'y',
'ÿ' => 'y',
'ŷ' => 'y',
'Ŵ' => 'W',
'ŵ' => 'w',
'Ź' => 'Z',
'Ż' => 'Z',
'Ž' => 'Z',
'ź' => 'z',
'ż' => 'z',
'ž' => 'z',
'Æ' => 'AE',
'Ǽ' => 'AE',
'ß' => 'ss',
'IJ' => 'IJ',
'ij' => 'ij',
'Œ' => 'OE',
'ƒ' => 'f',
'Þ' => 'TH',
'þ' => 'th',
'Є' => 'Ye',
'є' => 'ye',
] protected static array
Words that should not be inflected
[
'.*[nrlm]ese', '.*data', '.*deer', '.*fish', '.*measles', '.*ois',
'.*pox', '.*sheep', 'people', 'feedback', 'stadia', '.*?media',
'chassis', 'clippers', 'debris', 'diabetes', 'equipment', 'gallows',
'graffiti', 'headquarters', 'information', 'innings', 'news', 'nexus',
'pokemon', 'proceedings', 'research', 'sea[- ]bass', 'series', 'species', 'weather'
]
© 2005–2018 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.
https://api.cakephp.org/3.5/class-Cake.Utility.Inflector.html