PHP Class LazyRecord\Inflector

Datei anzeigen Open project: corneltek/lazyrecord Class Usage Examples

Public Properties

Property Type Description
$_camelize * Cached Camelize Inflections
$_classify * Classify cached inflecctions
$_humanize * Humanize cached inflections
$_plural * Plural inflector rules
$_pluralized * Cached array identity map of pluralized words.
$_singular * Singular inflector rules
$_singularized * Cached array identity map of singularized words.
$_tableize * Tablize cached inflections
$_transliteration * Default map of accented and special characters to ASCII characters
$_underscore * Cached Underscore Inflections
$_uninflected * Words that should not be inflected

Public Methods

Method Description
_cache ( string $type, string $key, string $value = false ) : string Cache inflected values, and return if already available.
camelize ( $lowerCaseAndUnderscoredWord ) : string Returns the given lower_case_and_underscored_word as a CamelCased word.
classify ( string $tableName ) : string Returns Cake model class name ("Person" for the database table "people".) for given database table.
getInstance ( ) : object Gets a reference to the Inflector object instance.
humanize ( $lowerCaseAndUnderscoredWord ) : string Returns the given underscored_word_group as a Human Readable Word Group.
pluralize ( string $word ) : string Return $word in plural form.
rules ( string $type, array $rules, boolean $reset = false ) Adds custom inflection $rules, of either 'plural', 'singular' or 'transliteration' $type.
singularize ( string $word ) : string Return $word in singular form.
slug ( string $string, string $replacement = '_', array $map = [] ) : string Returns a string with all spaces converted to underscores (by default), accented characters converted to non-accented characters, and non word characters removed.
tableize ( string $className ) : string Returns corresponding table name for given model $className. ("people" for the model class "Person").
underscore ( string $camelCasedWord ) : string Returns the given camelCasedWord as an underscored_word.
variable ( string $string ) : string Returns camelBacked version of an underscored string.

Method Details

_cache() public method

Cache inflected values, and return if already available.
public _cache ( string $type, string $key, string $value = false ) : string
$type string Inflection type
$key string Original value
$value string Inflected value
return string Inflected value, from cache

camelize() public method

Returns the given lower_case_and_underscored_word as a CamelCased word.
public camelize ( $lowerCaseAndUnderscoredWord ) : string
return string Camelized word. LikeThis.

classify() public method

Returns Cake model class name ("Person" for the database table "people".) for given database table.
public classify ( string $tableName ) : string
$tableName string Name of database table to get class name for
return string Class name

getInstance() public static method

Gets a reference to the Inflector object instance.
public static getInstance ( ) : object
return object

humanize() public method

(Underscores are replaced by spaces and capitalized following words.).
public humanize ( $lowerCaseAndUnderscoredWord ) : string
return string Human-readable string

pluralize() public method

Return $word in plural form.
public pluralize ( string $word ) : string
$word string Word in singular
return string Word in plural

rules() public method

### Usage: {{{ Inflector::rules('plural', array('/^(inflect)or$/i' => '\1ables')); Inflector::rules('plural', array( 'rules' => array('/^(inflect)ors$/i' => '\1ables'), 'uninflected' => array('dontinflectme'), 'irregular' => array('red' => 'redlings') )); Inflector::rules('transliteration', array('/å/' => 'aa')); }}}
public rules ( string $type, array $rules, boolean $reset = false )
$type string The type of inflection, either 'plural', 'singular' or 'transliteration'
$rules array Array of rules to be added.
$reset boolean If true, will unset default inflections for all new rules that are being defined in $rules.

singularize() public method

Return $word in singular form.
public singularize ( string $word ) : string
$word string Word in plural
return string Word in singular

slug() public method

Returns a string with all spaces converted to underscores (by default), accented characters converted to non-accented characters, and non word characters removed.
Deprecation: $map param will be removed in future versions. Use Inflector::rules() instead
public slug ( string $string, string $replacement = '_', array $map = [] ) : string
$string string the string you want to slug
$replacement string will replace keys in map
$map array extra elements to map to the replacement
return string

tableize() public method

Returns corresponding table name for given model $className. ("people" for the model class "Person").
public tableize ( string $className ) : string
$className string Name of class to get database table name for
return string Name of the database table for given class

underscore() public method

Returns the given camelCasedWord as an underscored_word.
public underscore ( string $camelCasedWord ) : string
$camelCasedWord string Camel-cased word to be "underscorized"
return string Underscore-syntaxed version of the $camelCasedWord

variable() public method

Returns camelBacked version of an underscored string.
public variable ( string $string ) : string
$string string
return string in variable form

Property Details

$_camelize public_oe property

* Cached Camelize Inflections
public $_camelize

$_classify public_oe property

* Classify cached inflecctions
public $_classify

$_humanize public_oe property

* Humanize cached inflections
public $_humanize

$_plural public_oe property

* Plural inflector rules
public $_plural

$_pluralized public_oe property

* Cached array identity map of pluralized words.
public $_pluralized

$_singular public_oe property

* Singular inflector rules
public $_singular

$_singularized public_oe property

* Cached array identity map of singularized words.
public $_singularized

$_tableize public_oe property

* Tablize cached inflections
public $_tableize

$_transliteration public_oe property

* Default map of accented and special characters to ASCII characters
public $_transliteration

$_underscore public_oe property

* Cached Underscore Inflections
public $_underscore

$_uninflected public_oe property

* Words that should not be inflected
public $_uninflected