Class yii\helpers\Inflector

Inheritanceyii\helpers\Inflector » yii\helpers\BaseInflector
Subclasseskartik\helpers\Enum
Available since version2.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

Hide inherited properties

PropertyTypeDescriptionDefined 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 transliterate() when intl isn't available. yii\helpers\BaseInflector
$transliterator mixed Either a \Transliterator, or a string from which a \Transliterator can be built for transliteration. yii\helpers\BaseInflector

Public Methods

Hide inherited methods

MethodDescriptionDefined 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. yii\helpers\BaseInflector
classify() Converts a table name to its class name. 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. yii\helpers\BaseInflector
titleize() Converts an underscored or CamelCase word into a English sentence. yii\helpers\BaseInflector
transliterate() Returns transliterated version of a string. 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

Hide inherited methods

MethodDescriptionDefined By
hasIntl() yii\helpers\BaseInflector

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
TRANSLITERATE_LOOSE 'Any-Latin; Latin-ASCII; [\u0080-\uffff] remove' Shortcut for Any-Latin; Latin-ASCII; [\u0080-\uffff] remove transliteration rule. The rule is loose, letters will be transliterated with the characters of Basic Latin Unicode Block. For example: 获取到 どちら Українська: ґ,є, Српска: ђ, њ, џ! ¿Español? will be transliterated to huo qu dao dochira Ukrainska: g,e, Srpska: d, n, d! Espanol?. Used in transliterate(). For detailed information see unicode normalization forms yii\helpers\BaseInflector
TRANSLITERATE_MEDIUM 'Any-Latin; Latin-ASCII' Shortcut for Any-Latin; Latin-ASCII transliteration rule. The rule is medium, letters will be transliterated to characters of Latin-1 (ISO 8859-1) ASCII table. For example: 获取到 どちら Українська: ґ,є, Српска: ђ, њ, џ! ¿Español? will be transliterated to huo qu dao dochira Ukrainsʹka: g,e, Srpska: d, n, d! ¿Espanol?. Used in transliterate(). For detailed information see unicode normalization forms yii\helpers\BaseInflector
TRANSLITERATE_STRICT 'Any-Latin; NFKD' Shortcut for Any-Latin; NFKD transliteration rule. The rule is strict, letters will be transliterated with the closest sound-representation chars. The result may contain any UTF-8 chars. For example: 获取到 どちら Українська: ґ,є, Српска: ђ, њ, џ! ¿Español? will be transliterated to huò qǔ dào dochira Ukraí̈nsʹka: g̀,ê, Srpska: đ, n̂, d̂! ¿Español?. Used in transliterate(). For detailed information see unicode normalization forms yii\helpers\BaseInflector