class Inflector (View source)

Methods

__construct(WordInflector $singularizer, WordInflector $pluralizer)

No description

tableize(string $word)

Converts a word into the format for a Doctrine table name. Converts 'ModelName' to 'model_name'.

classify(string $word)

Converts a word into the format for a Doctrine class name. Converts 'table_name' to 'TableName'.

camelize(string $word)

Camelizes a word. This uses the classify() method and turns the first character to lowercase.

string
capitalize(string $string, string $delimiters = " \n\t\r\0\v-")

Uppercases words with configurable delimiters between words.

string
singularize(string $word)

Returns a word in singular form.

string
pluralize(string $word)

Returns a word in plural form.

Details

__construct(WordInflector $singularizer, WordInflector $pluralizer)

Parameters

WordInflector $singularizer
WordInflector $pluralizer

tableize(string $word)

Converts a word into the format for a Doctrine table name. Converts 'ModelName' to 'model_name'.

Parameters

string $word

classify(string $word)

Converts a word into the format for a Doctrine class name. Converts 'table_name' to 'TableName'.

Parameters

string $word

camelize(string $word)

Camelizes a word. This uses the classify() method and turns the first character to lowercase.

Parameters

string $word

string capitalize(string $string, string $delimiters = " \n\t\r\0\v-")

Uppercases words with configurable delimiters between words.

Takes a string and capitalizes all of the words, like PHP's built-in ucwords function. This extends that behavior, however, by allowing the word delimiters to be configured, rather than only separating on whitespace.

Here is an example: capitalize($string); // Top-O-The-Morning To All_of_you! echo $inflector->capitalize($string, '-_ '); // Top-O-The-Morning To All_Of_You! ?>

Parameters

string $string The string to operate on.
string $delimiters A list of word separators.

Return Value

string The string with all delimiter-separated words capitalized.

string singularize(string $word)

Returns a word in singular form.

Parameters

string $word The word in plural form.

Return Value

string The word in singular form.

string pluralize(string $word)

Returns a word in plural form.

Parameters

string $word The word in singular form.

Return Value

string The word in plural form.