PHP 클래스 lithium\util\Inflector

Under_score a CamelCased word and vice versa. Replace spaces and special characters. Create a human readable word from the others. Used when consistency in naming conventions must be enforced.
파일 보기 프로젝트 열기: unionofrad/lithium 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_camelized array Contains a cache map of previously camelized words.
$_humanized array Contains a cache map of previously humanized words.
$_plural Contains the list of pluralization rules.
$_pluralized array Contains a cache map of previously pluralized words.
$_singular Contains the list of pluralization rules.
$_singularized array Contains a cache map of previously singularized words.
$_transliteration array Contains a default map of accented and special characters to ASCII characters. Can be extended or added to using Inflector::rules().
$_underscored array Contains a cache map of previously underscored words.
$_uninflected array Indexed array of words which are the same in both singular and plural form. You can add rules to this list using Inflector::rules().

공개 메소드들

메소드 설명
camelize ( string $word, boolean $cased = true ) : string Takes a under_scored word and turns it into a CamelCased or camelBack word
classify ( string $tableName ) : string Takes a under_scored table name and returns corresponding class name.
humanize ( string $word, string $separator = '_' ) : string Takes an under_scored version of a word and turns it into an human- readable form by replacing underscores with a space, and by upper casing the initial character.
pluralize ( string $word ) : string Changes the form of a word from singular to plural.
reset ( ) Clears local in-memory caches. Can be used to force a full-cache clear when updating inflection rules mid-way through request execution.
rules ( string $type, array $config = [] ) : mixed Gets or adds inflection and transliteration rules.
singularize ( string $word ) : string Changes the form of a word from plural to singular.
slug ( string $string, string $replacement = '-' ) : string Returns a string with all spaces converted to given replacement and non word characters removed. Maps special characters to ASCII using Inflector::$_transliteration, which can be updated using Inflector::rules().
tableize ( string $className ) : string Takes a CamelCased class name and returns corresponding under_scored table name.
underscore ( string $word ) : string Takes a CamelCased version of a word and turns it into an under_scored one.

보호된 메소드들

메소드 설명
_enclose ( string $string ) : string Enclose a string for preg matching.

메소드 상세

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

Enclose a string for preg matching.
protected static _enclose ( string $string ) : string
$string string String to enclose
리턴 string Enclosed string

camelize() 공개 정적인 메소드

Takes a under_scored word and turns it into a CamelCased or camelBack word
public static camelize ( string $word, boolean $cased = true ) : string
$word string An under_scored or slugged word (i.e. `'red_bike'` or `'red-bike'`).
$cased boolean If false, first character is not upper cased
리턴 string CamelCased version of the word (i.e. `'RedBike'`).

classify() 공개 정적인 메소드

Takes a under_scored table name and returns corresponding class name.
public static classify ( string $tableName ) : string
$tableName string Under_scored and plural table name (i.e. `'posts'`).
리턴 string CamelCased class name (i.e. `'Post'`).

humanize() 공개 정적인 메소드

Takes an under_scored version of a word and turns it into an human- readable form by replacing underscores with a space, and by upper casing the initial character.
public static humanize ( string $word, string $separator = '_' ) : string
$word string Under_scored version of a word (i.e. `'red_bike'`).
$separator string The separator character used in the initial string.
리턴 string Human readable version of the word (i.e. `'Red Bike'`).

pluralize() 공개 정적인 메소드

Changes the form of a word from singular to plural.
public static pluralize ( string $word ) : string
$word string Word in singular form.
리턴 string Word in plural form.

reset() 공개 정적인 메소드

Clears local in-memory caches. Can be used to force a full-cache clear when updating inflection rules mid-way through request execution.
public static reset ( )

rules() 공개 정적인 메소드

Gets or adds inflection and transliteration rules.
public static rules ( string $type, array $config = [] ) : mixed
$type string Either `'transliteration'`, `'uninflected'`, `'singular'` or `'plural'`.
$config array
리턴 mixed If `$config` is empty, returns the rules list specified by `$type`, otherwise returns `null`.

singularize() 공개 정적인 메소드

Changes the form of a word from plural to singular.
public static singularize ( string $word ) : string
$word string Word in plural form.
리턴 string Word in singular form.

slug() 공개 정적인 메소드

Returns a string with all spaces converted to given replacement and non word characters removed. Maps special characters to ASCII using Inflector::$_transliteration, which can be updated using Inflector::rules().
또한 보기: lithium\util\Inflector::rules()
public static slug ( string $string, string $replacement = '-' ) : string
$string string An arbitrary string to convert.
$replacement string The replacement to use for spaces.
리턴 string The converted string.

tableize() 공개 정적인 메소드

Takes a CamelCased class name and returns corresponding under_scored table name.
public static tableize ( string $className ) : string
$className string CamelCased class name (i.e. `'Post'`).
리턴 string Under_scored and plural table name (i.e. `'posts'`).

underscore() 공개 정적인 메소드

Takes a CamelCased version of a word and turns it into an under_scored one.
public static underscore ( string $word ) : string
$word string CamelCased version of a word (i.e. `'RedBike'`).
리턴 string Under_scored version of the workd (i.e. `'red_bike'`).

프로퍼티 상세

$_camelized 보호되어 있는 정적으로 프로퍼티

Contains a cache map of previously camelized words.
protected static array $_camelized
리턴 array

$_humanized 보호되어 있는 정적으로 프로퍼티

Contains a cache map of previously humanized words.
protected static array $_humanized
리턴 array

$_plural 보호되어 있는 정적으로 프로퍼티

Contains the list of pluralization rules.
또한 보기: lithium\util\Inflector::rules()
protected static $_plural

$_pluralized 보호되어 있는 정적으로 프로퍼티

Contains a cache map of previously pluralized words.
protected static array $_pluralized
리턴 array

$_singular 보호되어 있는 정적으로 프로퍼티

Contains the list of pluralization rules.
또한 보기: lithium\util\Inflector::rules()
protected static $_singular

$_singularized 보호되어 있는 정적으로 프로퍼티

Contains a cache map of previously singularized words.
protected static array $_singularized
리턴 array

$_transliteration 보호되어 있는 정적으로 프로퍼티

Contains a default map of accented and special characters to ASCII characters. Can be extended or added to using Inflector::rules().
또한 보기: lithium\util\Inflector::slug()
또한 보기: lithium\util\Inflector::rules()
protected static array $_transliteration
리턴 array

$_underscored 보호되어 있는 정적으로 프로퍼티

Contains a cache map of previously underscored words.
protected static array $_underscored
리턴 array

$_uninflected 보호되어 있는 정적으로 프로퍼티

Indexed array of words which are the same in both singular and plural form. You can add rules to this list using Inflector::rules().
또한 보기: lithium\util\Inflector::rules()
protected static array $_uninflected
리턴 array