Inflector
Joomla Framework String Inflector Class
The Inflector transforms words
| since |
1.0 |
|---|---|
| package |
Joomla Framework |
Methods
__construct
Protected constructor.
__construct() : mixed
| since |
1.0 |
|---|
Response
mixed
addCountableRule
Adds a countable word.
addCountableRule(mixed data) : \Joomla\String\Inflector
| since |
1.0 |
|---|
Arguments
- data
mixedA string or an array of strings to add.
Response
\Joomla\String\InflectorReturns this object to support chaining.
addPluraliseRule
Adds a pluralisation rule.
addPluraliseRule(mixed data) : \Joomla\String\Inflector
| since |
1.0 |
|---|
Arguments
- data
mixedA string or an array of regex rules to add.
Response
\Joomla\String\InflectorReturns this object to support chaining.
addRule
Adds inflection regex rules to the inflector.
addRule(mixed data, string ruleType) : void
| since |
1.0 |
|---|---|
| throws |
|
Arguments
- data
mixedA string or an array of strings or regex rules to add.- ruleType
stringThe rule type: singular | plural | countable
addSingulariseRule
Adds a singularisation rule.
addSingulariseRule(mixed data) : \Joomla\String\Inflector
| since |
1.0 |
|---|
Arguments
- data
mixedA string or an array of regex rules to add.
Response
\Joomla\String\InflectorReturns this object to support chaining.
addWord
Adds a specific singular-plural pair for a word.
addWord(string singular, string plural = null) : \Joomla\String\Inflector
| since |
1.0 |
|---|
Arguments
- singular
stringThe singular form of the word.- plural
stringThe plural form of the word. If omitted, it is assumed the singular and plural are identical.
Response
\Joomla\String\InflectorReturns this object to support chaining.
getCachedPlural
Gets an inflected word from the cache where the singular form is supplied.
getCachedPlural(string singular) : string|bool
| since |
1.0 |
|---|
Arguments
- singular
stringA singular form of a word.
Response
string|boolThe cached inflection or false if none found.
getCachedSingular
Gets an inflected word from the cache where the plural form is supplied.
getCachedSingular(string plural) : string|bool
| since |
1.0 |
|---|
Arguments
- plural
stringA plural form of a word.
Response
string|boolThe cached inflection or false if none found.
getInstance
Gets an instance of the JStringInflector singleton.
getInstance(bool new = false) : \Joomla\String\Inflector
| since |
1.0 |
|---|
Arguments
- new
boolIf true (default is false), returns a new instance regardless if one exists. This argument is mainly used for testing.
Response
\Joomla\String\Inflector
isCountable
Checks if a word is countable.
isCountable(string word) : bool
| since |
1.0 |
|---|
Arguments
- word
stringThe string input.
Response
boolTrue if word is countable, false otherwise.
isPlural
Checks if a word is in a plural form.
isPlural(string word) : bool
| since |
1.0 |
|---|
Arguments
- word
stringThe string input.
Response
boolTrue if word is plural, false if not.
isSingular
Checks if a word is in a singular form.
isSingular(string word) : bool
| since |
1.0 |
|---|
Arguments
- word
stringThe string input.
Response
boolTrue if word is singular, false if not.
matchRegexRule
Execute a regex from rules.
matchRegexRule(string word, string ruleType) : string|bool
The 'plural' rule type expects a singular word. The 'singular' rule type expects a plural word.
| since |
1.0 |
|---|
Arguments
- word
stringThe string input.- ruleType
stringString (eg, singular|plural)
Response
string|boolAn inflected string, or false if no rule could be applied.
setCache
Sets an inflected word in the cache.
setCache(string singular, string plural = null) : void
| since |
1.0 |
|---|
Arguments
- singular
stringThe singular form of the word.- plural
stringThe plural form of the word. If omitted, it is assumed the singular and plural are identical.
toPlural
Converts a word into its plural form.
toPlural(string word) : string|bool
| since |
1.0 |
|---|
Arguments
- word
stringThe singular word to pluralise.
Response
string|boolAn inflected string, or false if no rule could be applied.
toSingular
Converts a word into its singular form.
toSingular(string word) : string|bool
| since |
1.0 |
|---|
Arguments
- word
stringThe plural word to singularise.
Response
string|boolAn inflected string, or false if no rule could be applied.
Properties
instance
The singleton instance.
| since |
1.0 |
|---|
Type(s)
\Joomla\String\Inflector
rules
The inflector rules for singularisation, pluralisation and countability.
| since |
1.0 |
|---|
Type(s)
array
cache
Cached inflections.
The array is in the form [singular => plural]
| since |
1.0 |
|---|
Type(s)
string[]