PHP Class Ouzo\Utilities\Inflector

From Doctrine comments: Pluralize & Singularize implementation are borrowed from CakePHP with some modifications.
Exibir arquivo Open project: letsdrink/ouzo Class Usage Examples

Public Methods

Method Description
pluralize ( string $word ) : string Returns a word in plural form.
reset ( ) : void Clears Inflectors inflected value caches, and resets the inflection rules to the initial values.
rules ( string $type, array $rules, boolean $reset = false ) : void Adds custom inflection $rules, of either 'plural' or 'singular' $type.
singularize ( string $word ) : string Returns a word in singular form.

Method Details

pluralize() public static method

Returns a word in plural form.
public static pluralize ( string $word ) : string
$word string The word in singular form.
return string The word in plural form.

reset() public static method

Clears Inflectors inflected value caches, and resets the inflection rules to the initial values.
public static reset ( ) : void
return void

rules() public static 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') )); }}}
public static rules ( string $type, array $rules, boolean $reset = false ) : void
$type string The type of inflection, either 'plural' or 'singular'
$rules array An array of rules to be added.
$reset boolean If true, will unset default inflections for all new rules that are being defined in $rules.
return void

singularize() public static method

Returns a word in singular form.
public static singularize ( string $word ) : string
$word string The word in plural form.
return string The word in singular form.