class StringInflector (View source)

Windwalker Framework String Inflector Class

The Inflector transforms words. This class is based on Joomla String package

Methods

__construct()

Protected constructor.

addCountableRule(mixed $data)

Adds a countable word.

addWord(string $singular, string $plural = null)

Adds a specific singular-plural pair for a word.

addPluraliseRule(mixed $data)

Adds a pluralisation rule.

addSingulariseRule(mixed $data)

Adds a singularisation rule.

static StringInflector
getInstance(boolean $new = false)

Gets an instance of the JStringInflector singleton.

boolean
isCountable(string $word)

Checks if a word is countable.

boolean
isPlural(string $word)

Checks if a word is in a plural form.

boolean
isSingular(string $word)

Checks if a word is in a singular form.

mixed
toPlural(string $word)

Converts a word into its plural form.

mixed
toSingular(string $word)

Converts a word into its singular form.

Details

at line line 88
__construct()

Protected constructor.

at line line 249
StringInflector addCountableRule(mixed $data)

Adds a countable word.

Parameters

mixed $data A string or an array of strings to add.

Return Value

StringInflector Returns this object to support chaining.

at line line 266
StringInflector addWord(string $singular, string $plural = null)

Adds a specific singular-plural pair for a word.

Parameters

string $singular The singular form of the word.
string $plural The plural form of the word. If omitted, it is assumed the singular and plural are identical.

Return Value

StringInflector Returns this object to support chaining.

at line line 282
StringInflector addPluraliseRule(mixed $data)

Adds a pluralisation rule.

Parameters

mixed $data A string or an array of regex rules to add.

Return Value

StringInflector Returns this object to support chaining.

at line line 298
StringInflector addSingulariseRule(mixed $data)

Adds a singularisation rule.

Parameters

mixed $data A string or an array of regex rules to add.

Return Value

StringInflector Returns this object to support chaining.

at line line 315
static StringInflector getInstance(boolean $new = false)

Gets an instance of the JStringInflector singleton.

Parameters

boolean $new If true (default is false), returns a new instance regardless if one exists. This argument is mainly used for testing.

Return Value

StringInflector

at line line 338
boolean isCountable(string $word)

Checks if a word is countable.

Parameters

string $word The string input.

Return Value

boolean True if word is countable, false otherwise.

at line line 352
boolean isPlural(string $word)

Checks if a word is in a plural form.

Parameters

string $word The string input.

Return Value

boolean True if word is plural, false if not.

at line line 375
boolean isSingular(string $word)

Checks if a word is in a singular form.

Parameters

string $word The string input.

Return Value

boolean True if word is singular, false if not.

at line line 398
mixed toPlural(string $word)

Converts a word into its plural form.

Parameters

string $word The singular word to pluralise.

Return Value

mixed An inflected string, or false if no rule could be applied.

at line line 436
mixed toSingular(string $word)

Converts a word into its singular form.

Parameters

string $word The plural word to singularise.

Return Value

mixed An inflected string, or false if no rule could be applied.