\JStringInflector
Joomla Platform String Inflector Class
The Inflector transforms words
Synopsis
class JStringInflector
{
- // members
- private JStringInflector $_instance;
- private $_rules;
- private $_cache;
- // methods
- protected void __construct()
- private void _addRule()
- private mixed _getCachedPlural()
- private mixed _getCachedSingular()
- private mixed _matchRegexRule()
- private void _setCache()
- public JStringInflector addCountableRule()
- public JStringInflector addWord()
- public JStringInflector addPluraliseRule()
- public JStringInflector addSingulariseRule()
- public static JStringInflector getInstance()
- public boolean isCountable()
- public boolean isPlural()
- public boolean isSingular()
- public mixed toPlural()
- public mixed toSingular()
Members
private
- $_cache
—
array
Cached inflections. - $_instance
—
JStringInflector
The singleton instance. - $_rules
—
array
The inflector rules for singularisation, pluralisation and countability.
Methods
private
- _addRule() — Adds inflection regex rules to the inflector.
- _getCachedPlural() — Gets an inflected word from the cache where the singular form is supplied.
- _getCachedSingular() — Gets an inflected word from the cache where the plural form is supplied.
- _matchRegexRule() — Execute a regex from rules.
- _setCache() — Sets an inflected word in the cache.
public
- addCountableRule() — Adds a countable word.
- addPluraliseRule() — Adds a pluralisation rule.
- addSingulariseRule() — Adds a singularisation rule.
- addWord() — Adds a specific singular-plural pair for a word.
- getInstance() — Gets an instance of the JStringInflector singleton.
- isCountable() — Checks if a word is countable.
- isPlural() — Checks if a word is in a plural form.
- isSingular() — Checks if a word is in a singular form.
- toPlural() — Converts a word into its plural form.
- toSingular() — Converts a word into its singular form.