Skip to content

Inflector ​

Type
Class
Namespace
craft\helpers
Inherits
craft\helpers\Inflector » yii\helpers\Inflector » yii\helpers\BaseInflector
Since
5.4.0

View source

Public Properties ​

PropertyDescription
pluralsarray – The rules for converting a word into its plural form.
singularsarray – The rules for converting a word into its singular form.
specialsarray – The special rules for converting a word between its plural form and singular form.
transliterationarray – Fallback map for transliteration used by transliterate() when intl isn't available.
transliteratormixed – Either a Transliterator, or a string from which a Transliterator can be built for transliteration.

Public Methods ​

MethodDescription
camel2id()Converts a CamelCase name into an ID in lowercase.
camel2words()Converts a CamelCase name into space-separated words.
camelize()Returns given word as CamelCased.
classify()Converts a table name to its class name.
humanize()Returns a human-readable string from $word.
id2camel()Converts an ID into a CamelCase name.
ordinalize()Converts number to its ordinal English form. For example, converts 13 to 13th, 2 to 2nd .
pluralize()Converts a word to its plural form.
sentence()
singularize()Returns the singular of the $word.
slug()Returns a string with all spaces converted to given replacement, non word characters removed and the rest of characters transliterated.
tableize()Converts a class name to its table name (pluralized) naming conventions.
titleize()Converts an underscored or CamelCase word into a English sentence.
transliterate()Returns transliterated version of a string.
underscore()Converts any "CamelCased" into an "underscored_word".
variablize()Same as camelize but first char is in lowercase.

sentence() ​

View source

Arguments ​

  • $words
  • $twoWordsConnector
  • $lastWordConnector
  • $connector

Protected Methods ​

MethodDescription
hasIntl()

Constants ​

ConstantDescription
TRANSLITERATE_LOOSEShortcut for Any-Latin; Latin-ASCII; [\u0080-\uffff] remove transliteration rule.
TRANSLITERATE_MEDIUMShortcut for Any-Latin; Latin-ASCII transliteration rule.
TRANSLITERATE_STRICTShortcut for Any-Latin; NFKD transliteration rule.