public static
ICanBoogie\Inflections
|
#
get( string $locale = ICanBoogie\INFLECTOR_DEFAULT_LOCALE )
Returns inflections for the specified locale.
Returns inflections for the specified locale.
Note: Inflections are shared for the same locale. If you need to alter an instance you
MUST clone it first, otherwise your changes will affect others.
Parameters
Returns
|
public
|
|
public
ICanBoogie\Inflections
|
#
acronym( string $acronym )
Specifies a new acronym. An acronym must be specified as it will appear
in a camelized string. An underscore string that contains the acronym
will retain the acronym when passed to camelize, humanize, or
titleize. A camelized string that contains the acronym will maintain
the acronym when titleized or humanized, and will convert the acronym
into a non-delimited single lowercase word when passed to underscore.
Specifies a new acronym. An acronym must be specified as it will appear
in a camelized string. An underscore string that contains the acronym
will retain the acronym when passed to camelize, humanize, or
titleize. A camelized string that contains the acronym will maintain
the acronym when titleized or humanized, and will convert the acronym
into a non-delimited single lowercase word when passed to underscore.
$this->acronym('HTML');
$this->titleize('html');
$this->camelize('html');
$this->underscore('MyHTML');
The acronym, however, must occur as a delimited unit and not be part of
another word for conversions to recognize it:
$this->acronym('HTTP');
$this->camelize('my_http_delimited');
$this->camelize('https');
$this->underscore('HTTPS');
$this->acronym('HTTPS');
$this->camelize('https');
$this->underscore('HTTPS');
Note: Acronyms that are passed to pluralize will no longer be
recognized, since the acronym will not occur as a delimited unit in the
pluralized result. To work around this, you must specify the pluralized
form as an acronym as well:
$this->acronym('API');
$this->camelize($this->pluralize('api'));
$this->acronym('APIs');
$this->camelize($this->pluralize('api'));
ICanBoogie\Inflections::acronym() may be used to specify any word that contains an acronym or
otherwise needs to maintain a non-standard capitalization. The only
restriction is that the word must begin with a capital letter.
$this->acronym('RESTful');
$this->underscore('RESTful');
$this->underscore('RESTfulController');
$this->titleize('RESTfulController');
$this->camelize('restful');
$this->camelize('restful_controller');
$this->acronym('McHammer');
$this->underscore('McHammer');
$this->camelize('mchammer');
Parameters
Returns
|
public
ICanBoogie\Inflections
|
#
plural( string $rule, string $replacement )
Specifies a new pluralization rule and its replacement.
Specifies a new pluralization rule and its replacement.
$this->plural('/^(ax|test)is$/i', '\1es');
$this->plural('/(buffal|tomat)o$/i', '\1oes');
$this->plural('/^(m|l)ouse$/i', '\1ice');
Parameters
- $rule
- A regex string.
- $replacement
The replacement should always be a string that may include
references to the matched data from the rule.
Returns
|
public
ICanBoogie\Inflections
|
#
singular( string $rule, string $replacement )
Specifies a new singularization rule and its replacement.
Specifies a new singularization rule and its replacement.
$this->singular('/(n)ews$/i', '\1ews');
$this->singular('/([^aeiouy]|qu)ies$/i', '\1y');
$this->singular('/(quiz)zes$/i', '\1');
Parameters
- $rule
- A regex string.
- $replacement
The replacement should always be a string that may include
references to the matched data from the rule.
Returns
|
public
ICanBoogie\Inflections
|
#
irregular( string $singular, string $plural )
Specifies a new irregular that applies to both pluralization and singularization at the
same time. This can only be used for strings, not regular expressions. You simply pass
the irregular in singular and plural form.
Specifies a new irregular that applies to both pluralization and singularization at the
same time. This can only be used for strings, not regular expressions. You simply pass
the irregular in singular and plural form.
$this->irregular('child', 'children');
$this->irregular('person', 'people');
Parameters
Returns
|
public
ICanBoogie\Inflections
|
#
uncountable( string|array $word )
Add uncountable words that shouldn't be attempted inflected.
Add uncountable words that shouldn't be attempted inflected.
$this->uncountable('money');
$this->uncountable(explode(' ', 'money information rice'));
Parameters
Returns
|
public
ICanBoogie\Inflections
|
#
human( string $rule, string $replacement )
Specifies a humanized form of a string by a regular expression rule or by a string mapping.
When using a regular expression based replacement, the normal humanize formatting is
called after the replacement. When a string is used, the human form should be specified
as desired (example: 'The name', not 'the_name').
Specifies a humanized form of a string by a regular expression rule or by a string mapping.
When using a regular expression based replacement, the normal humanize formatting is
called after the replacement. When a string is used, the human form should be specified
as desired (example: 'The name', not 'the_name').
$this->human('/_cnt$/i', '\1_count');
$this->human('legacy_col_person_name', 'Name');
Parameters
- $rule
A regular expression rule or a string mapping. Strings that starts with
"/", "#" or "~" are recognized as regular expressions.
- $replacement
Returns
|