PHP 클래스 yii\helpers\BaseInflector

Do not use BaseInflector. Use Inflector instead.
부터: 2.0
저자: Antonio Ramirez ([email protected])
저자: Alexander Makarov ([email protected])
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$plurals the rules for converting a word into its plural form. The keys are the regular expressions and the values are the corresponding replacements.
$singulars the rules for converting a word into its singular form. The keys are the regular expressions and the values are the corresponding replacements.
$specials the special rules for converting a word between its plural form and singular form. The keys are the special words in singular form, and the values are the corresponding plural form.
$transliteration fallback map for transliteration used by BaseInflector::transliterate when intl isn't available.
$transliterator Either a [[\Transliterator]], or a string from which a [[\Transliterator]] can be built for transliteration. Used by BaseInflector::transliterate when intl is available. Defaults to [[TRANSLITERATE_LOOSE]]

공개 메소드들

메소드 설명
camel2id ( string $name, string $separator = '-', boolean | string $strict = false ) : string Converts a CamelCase name into an ID in lowercase.
camel2words ( string $name, boolean $ucwords = true ) : string Converts a CamelCase name into space-separated words.
camelize ( string $word ) : string 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"
classify ( string $tableName ) : string Converts a table name to its class name. For example, converts "people" to "Person"
humanize ( string $word, boolean $ucAll = false ) : string Returns a human-readable string from $word
id2camel ( string $id, string $separator = '-' ) : string Converts an ID into a CamelCase name.
ordinalize ( integer $number ) : string Converts number to its ordinal English form. For example, converts 13 to 13th, 2 to 2nd .
pluralize ( string $word ) : string Converts a word to its plural form.
sentence ( array $words, string $twoWordsConnector = ' and ', string $lastWordConnector = null, string $connector = ', ' ) : string Converts a list of words into a sentence.
singularize ( string $word ) : string Returns the singular of the $word
slug ( string $string, string $replacement = '-', boolean $lowercase = true ) : string Returns a string with all spaces converted to given replacement, non word characters removed and the rest of characters transliterated.
tableize ( string $className ) : string Converts a class name to its table name (pluralized) naming conventions. For example, converts "Person" to "people"
titleize ( string $words, boolean $ucAll = false ) : string Converts an underscored or CamelCase word into a English sentence.
transliterate ( string $string, string | Transliterator $transliterator = null ) : string Returns transliterated version of a string.
underscore ( string $words ) : string Converts any "CamelCased" into an "underscored_word".
variablize ( string $word ) : string Same as camelize but first char is in lowercase.

보호된 메소드들

메소드 설명
hasIntl ( ) : boolean

메소드 상세

camel2id() 공개 정적인 메소드

Words in the ID may be concatenated using the specified character (defaults to '-'). For example, 'PostTag' will be converted to 'post-tag'.
public static camel2id ( string $name, string $separator = '-', boolean | string $strict = false ) : string
$name string the string to be converted
$separator string the character used to concatenate the words in the ID
$strict boolean | string whether to insert a separator between two consecutive uppercase chars, defaults to false
리턴 string the resulting ID

camel2words() 공개 정적인 메소드

For example, 'PostTag' will be converted to 'Post Tag'.
public static camel2words ( string $name, boolean $ucwords = true ) : string
$name string the string to be converted
$ucwords boolean whether to capitalize the first letter in each word
리턴 string the resulting words

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"
또한 보기: variablize()
public static camelize ( string $word ) : string
$word string the word to CamelCase
리턴 string

classify() 공개 정적인 메소드

Converts a table name to its class name. For example, converts "people" to "Person"
public static classify ( string $tableName ) : string
$tableName string
리턴 string

hasIntl() 보호된 정적인 메소드

protected static hasIntl ( ) : boolean
리턴 boolean if intl extension is loaded

humanize() 공개 정적인 메소드

Returns a human-readable string from $word
public static humanize ( string $word, boolean $ucAll = false ) : string
$word string the string to humanize
$ucAll boolean whether to set all words to uppercase or not
리턴 string

id2camel() 공개 정적인 메소드

Words in the ID separated by $separator (defaults to '-') will be concatenated into a CamelCase name. For example, 'post-tag' is converted to 'PostTag'.
public static id2camel ( string $id, string $separator = '-' ) : string
$id string the ID to be converted
$separator string the character used to separate the words in the ID
리턴 string the resulting CamelCase name

ordinalize() 공개 정적인 메소드

..
public static ordinalize ( integer $number ) : string
$number integer the number to get its ordinal value
리턴 string

pluralize() 공개 정적인 메소드

Note that this is for English only! For example, 'apple' will become 'apples', and 'child' will become 'children'.
public static pluralize ( string $word ) : string
$word string the word to be pluralized
리턴 string the pluralized word

sentence() 공개 정적인 메소드

Special treatment is done for the last few words. For example, php $words = ['Spain', 'France']; echo Inflector::sentence($words); output: Spain and France $words = ['Spain', 'France', 'Italy']; echo Inflector::sentence($words); output: Spain, France and Italy $words = ['Spain', 'France', 'Italy']; echo Inflector::sentence($words, ' & '); output: Spain, France & Italy
부터: 2.0.1
public static sentence ( array $words, string $twoWordsConnector = ' and ', string $lastWordConnector = null, string $connector = ', ' ) : string
$words array the words to be converted into an string
$twoWordsConnector string the string connecting words when there are only two
$lastWordConnector string the string connecting the last two words. If this is null, it will take the value of `$twoWordsConnector`.
$connector string the string connecting words other than those connected by $lastWordConnector and $twoWordsConnector
리턴 string the generated sentence

singularize() 공개 정적인 메소드

Returns the singular of the $word
public static singularize ( string $word ) : string
$word string the english word to singularize
리턴 string Singular noun.

slug() 공개 정적인 메소드

If intl extension isn't available uses fallback that converts latin characters only and removes the rest. You may customize characters map via $transliteration property of the helper.
public static slug ( string $string, string $replacement = '-', boolean $lowercase = true ) : string
$string string An arbitrary string to convert
$replacement string The replacement to use for spaces
$lowercase boolean whether to return the string in lowercase or not. Defaults to `true`.
리턴 string The converted string.

tableize() 공개 정적인 메소드

Converts a class name to its table name (pluralized) naming conventions. For example, converts "Person" to "people"
public static tableize ( string $className ) : string
$className string the class name for getting related table_name
리턴 string

titleize() 공개 정적인 메소드

Converts an underscored or CamelCase word into a English sentence.
public static titleize ( string $words, boolean $ucAll = false ) : string
$words string
$ucAll boolean whether to set all words to uppercase
리턴 string

transliterate() 공개 정적인 메소드

If intl extension isn't available uses fallback that converts latin characters only and removes the rest. You may customize characters map via $transliteration property of the helper.
부터: 2.0.7 this method is public.
public static transliterate ( string $string, string | Transliterator $transliterator = null ) : string
$string string input string
$transliterator string | Transliterator either a [[\Transliterator]] or a string from which a [[\Transliterator]] can be built.
리턴 string

underscore() 공개 정적인 메소드

Converts any "CamelCased" into an "underscored_word".
public static underscore ( string $words ) : string
$words string the word(s) to underscore
리턴 string

variablize() 공개 정적인 메소드

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"
public static variablize ( string $word ) : string
$word string to lowerCamelCase
리턴 string

프로퍼티 상세

$plurals 공개적으로 정적으로 프로퍼티

the rules for converting a word into its plural form. The keys are the regular expressions and the values are the corresponding replacements.
public static $plurals

$singulars 공개적으로 정적으로 프로퍼티

the rules for converting a word into its singular form. The keys are the regular expressions and the values are the corresponding replacements.
public static $singulars

$specials 공개적으로 정적으로 프로퍼티

the special rules for converting a word between its plural form and singular form. The keys are the special words in singular form, and the values are the corresponding plural form.
public static $specials

$transliteration 공개적으로 정적으로 프로퍼티

fallback map for transliteration used by BaseInflector::transliterate when intl isn't available.
public static $transliteration

$transliterator 공개적으로 정적으로 프로퍼티

Either a [[\Transliterator]], or a string from which a [[\Transliterator]] can be built for transliteration. Used by BaseInflector::transliterate when intl is available. Defaults to [[TRANSLITERATE_LOOSE]]
또한 보기: http://php.net/manual/en/transliterator.transliterate.php
public static $transliterator