Class yii\helpers\Inflector
Inheritance | yii\helpers\Inflector » yii\helpers\BaseInflector |
---|---|
Available since version | 2.0 |
Source Code | https://github.com/yiisoft/yii2/blob/master/framework/helpers/Inflector.php |
Inflector pluralizes and singularizes English nouns. It also contains some other useful methods.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$plurals | array | The rules for converting a word into its plural form. | yii\helpers\BaseInflector |
$singulars | array | The rules for converting a word into its singular form. | yii\helpers\BaseInflector |
$specials | array | The special rules for converting a word between its plural form and singular form. | yii\helpers\BaseInflector |
$transliteration | array | Fallback map for transliteration used by slug() when intl isn't available. | yii\helpers\BaseInflector |
$transliterator | mixed | Either a \yii\helpers\Transliterator or a string from which a \yii\helpers\Transliterator can be built for transliteration used by slug() when intl is available. | yii\helpers\BaseInflector |
Public Methods
Method | Description | Defined By |
---|---|---|
camel2id() | Converts a CamelCase name into an ID in lowercase. | yii\helpers\BaseInflector |
camel2words() | Converts a CamelCase name into space-separated words. | yii\helpers\BaseInflector |
camelize() | Returns given word as CamelCased Converts a word like "send_email" to "SendEmail". It will remove non alphanumeric character from the word, so "who's online" will be converted to "WhoSOnline" | yii\helpers\BaseInflector |
classify() | Converts a table name to its class name. For example, converts "people" to "Person" | yii\helpers\BaseInflector |
humanize() | Returns a human-readable string from $word | yii\helpers\BaseInflector |
id2camel() | Converts an ID into a CamelCase name. | yii\helpers\BaseInflector |
ordinalize() | Converts number to its ordinal English form. For example, converts 13 to 13th, 2 to 2nd . | yii\helpers\BaseInflector |
pluralize() | Converts a word to its plural form. | yii\helpers\BaseInflector |
sentence() | Converts a list of words into a sentence. | yii\helpers\BaseInflector |
singularize() | Returns the singular of the $word | yii\helpers\BaseInflector |
slug() | Returns a string with all spaces converted to given replacement, non word characters removed and the rest of characters transliterated. | yii\helpers\BaseInflector |
tableize() | Converts a class name to its table name (pluralized) naming conventions. For example, converts "Person" to "people" | yii\helpers\BaseInflector |
titleize() | Converts an underscored or CamelCase word into a English sentence. | yii\helpers\BaseInflector |
underscore() | Converts any "CamelCased" into an "underscored_word". | yii\helpers\BaseInflector |
variablize() | Same as camelize but first char is in lowercase. | yii\helpers\BaseInflector |
Protected Methods
Method | Description | Defined By |
---|---|---|
hasIntl() | yii\helpers\BaseInflector | |
transliterate() | Returns transliterated version of a string. | yii\helpers\BaseInflector |