class Inflector (View source)

Constants

ACCENTED_CHARACTERS

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.

seemsUtf8(string $string)

Checks if the given string seems like it has utf8 characters in it.

string
unaccent(string $string)

Remove any illegal characters, accents, etc.

string
urlize(string $string)

Convert any passed string to a url friendly string.

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.

seemsUtf8(string $string)

Checks if the given string seems like it has utf8 characters in it.

Parameters

string $string The string to check for utf8 characters in.

string unaccent(string $string)

Remove any illegal characters, accents, etc.

Parameters

string $string String to unaccent

Return Value

string Unaccented string

string urlize(string $string)

Convert any passed string to a url friendly string.

Converts 'My first blog post' to 'my-first-blog-post'

Parameters

string $string String to urlize.

Return Value

string Urlized string.

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.