PHP Класс Ouzo\Utilities\Inflector

From Doctrine comments: Pluralize & Singularize implementation are borrowed from CakePHP with some modifications.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Описание методов

pluralize() публичный статический Метод

Returns a word in plural form.
public static pluralize ( string $word ) : string
$word string The word in singular form.
Результат string The word in plural form.

reset() публичный статический Метод

Clears Inflectors inflected value caches, and resets the inflection rules to the initial values.
public static reset ( ) : void
Результат void

rules() публичный статический Метод

### 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.
Результат void

singularize() публичный статический Метод

Returns a word in singular form.
public static singularize ( string $word ) : string
$word string The word in plural form.
Результат string The word in singular form.