yii\helpers\Inflector - Yii2 类参考手册

Class yii\helpers\Inflector

Inheritanceyii\helpers\Inflector » yii\helpers\BaseInflector
Available since version2.0

Inflector pluralizes and singularizes English nouns. It also contains some other useful methods.

Public Properties

隐藏继承的属性 Hide inherited 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 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

方法 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. 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

方法 Method简介 Description定义在 Defined By
hasIntl() yii\helpers\BaseInflector

常量 Constants

隐藏继承的常量 Hide inherited constants

常量 Constant值 Value简介 Description定义在 Defined 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