Pluralize and singularize English words.
Inflector pluralizes and singularizes English nouns. Used by CakePHP's naming conventions throughout the framework.
array<string, mixed>
Method cache array.
array
The initial state of Inflector so reset() works.
array<string, string>
Irregular rules
array<string, string>
Plural inflector rules
array<string, string>
Singular inflector rules
array<string>
Words that should not be inflected
Cache inflected values, and return if already available
Returns the input lower_case_delimited_string as a CamelCasedString.
Returns Cake model class name ("Person" for the database table "people".) for given database table.
Returns the input CamelCasedString as an dashed-string.
Expects a CamelCasedInputString, and produces a lower_case_delimited_string
Returns the input lower_case_delimited_string as 'A Human Readable String'. (Underscores are replaced by spaces and capitalized following words.)
Return $word in plural form.
Clears Inflectors inflected value caches. And resets the inflection rules to the initial values.
Adds custom inflection $rules, of either 'plural', 'singular', 'uninflected' or 'irregular' $type.
Return $word in singular form.
Returns corresponding table name for given model $className. ("people" for the model class "Person").
Returns the input CamelCasedString as an underscored_string.
Returns camelBacked version of an underscored string.
_cache(string $type, string $key, string|false $value = false): string|false
Cache inflected values, and return if already available
string
$type Inflection type
string
$key Original value
string|false
$value optional Inflected value
string|false
camelize(string $string, string $delimiter = '_'): string
Returns the input lower_case_delimited_string as a CamelCasedString.
string
$string String to camelize
string
$delimiter optional the delimiter in the input string
string
classify(string $tableName): string
Returns Cake model class name ("Person" for the database table "people".) for given database table.
string
$tableName Name of database table to get class name for
string
dasherize(string $string): string
Returns the input CamelCasedString as an dashed-string.
Also replaces underscores with dashes
string
$string The string to dasherize.
string
delimit(string $string, string $delimiter = '_'): string
Expects a CamelCasedInputString, and produces a lower_case_delimited_string
string
$string String to delimit
string
$delimiter optional the character to use as a delimiter
string
humanize(string $string, string $delimiter = '_'): string
Returns the input lower_case_delimited_string as 'A Human Readable String'. (Underscores are replaced by spaces and capitalized following words.)
string
$string String to be humanized
string
$delimiter optional the character to replace with a space
string
pluralize(string $word): string
Return $word in plural form.
string
$word Word in singular
string
reset(): void
Clears Inflectors inflected value caches. And resets the inflection rules to the initial values.
void
rules(string $type, array $rules, bool $reset = false): void
Adds custom inflection $rules, of either 'plural', 'singular', 'uninflected' or 'irregular' $type.
Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']); Inflector::rules('irregular', ['red' => 'redlings']); Inflector::rules('uninflected', ['dontinflectme']);
string
$type The type of inflection, either 'plural', 'singular', or 'uninflected'.
array
$rules Array of rules to be added.
bool
$reset optional If true, will unset default inflections for all new rules that are being defined in $rules.
void
singularize(string $word): string
Return $word in singular form.
string
$word Word in plural
string
tableize(string $className): string
Returns corresponding table name for given model $className. ("people" for the model class "Person").
string
$className Name of class to get database table name for
string
underscore(string $string): string
Returns the input CamelCasedString as an underscored_string.
Also replaces dashes with underscores
string
$string CamelCasedString to be "underscorized"
string
variable(string $string): string
Returns camelBacked version of an underscored string.
string
$string String to convert.
string
Method cache array.
array<string, mixed>
The initial state of Inflector so reset() works.
array
Irregular rules
array<string, string>
Plural inflector rules
array<string, string>
Singular inflector rules
array<string, string>
Words that should not be inflected
array<string>
© 2005–present 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/4.4/class-Cake.Utility.Inflector.html