Methods summary
public
|
#
__construct( )
Constructor.
Stores a map of the uncountable words for quicker checks.
|
public
|
#
uncountable( string $word )
Adds an uncountable word.
Adds an uncountable word.
Parameters
- $word
- The uncountable word.
|
public
string
|
#
pluralize( string $word )
Singular English word to pluralize.
Singular English word to pluralize.
Parameters
Returns
string Plural form of $word.
|
public
string
|
#
singularize( string $word )
Plural English word to singularize.
Plural English word to singularize.
Parameters
- $word
- Word to singularize.
Returns
string Singular form of $word.
|
public
string
|
#
camelize( string $word, string $firstLetter = 'upper' )
Camel-cases a word.
Parameters
- $word
- The word to camel-case.
- $firstLetter
- <p>Whether to upper or lower case the first.
letter of each slash-separated section.</p>
Returns
string Camelized $word
|
public
|
#
titleize( mixed $word )
Capitalizes all the words and replaces some characters in the string to
create a nicer looking title.
Capitalizes all the words and replaces some characters in the string to
create a nicer looking title.
Titleize is meant for creating pretty output.
See:
- http://daringfireball.net/2008/05/title_case
- http://daringfireball.net/2008/08/title_case_update
Examples:
1. titleize("man from the boondocks") => "Man From The Boondocks"
2. titleize("x-men: the last stand") => "X Men: The Last Stand"
|
public
|
#
underscore( mixed $camelCasedWord )
The reverse of camelize().
The reverse of camelize().
Makes an underscored form from the expression in the string.
Examples:
1. underscore("ActiveRecord") => "active_record"
2. underscore("ActiveRecord_Errors") => "active_record_errors"
|
public
|
#
dasherize( mixed $underscoredWord )
Replaces underscores with dashes in the string.
Replaces underscores with dashes in the string.
Example:
1. dasherize("puni_puni") => "puni-puni"
|
public
|
#
humanize( mixed $lowerCaseAndUnderscoredWord )
Capitalizes the first word and turns underscores into spaces and strips
_id.
Capitalizes the first word and turns underscores into spaces and strips
_id.
Like titleize(), this is meant for creating pretty output.
Examples:
1. humanize("employee_salary") => "Employee salary"
2. humanize("author_id") => "Author"
|
public
|
#
demodulize( mixed $classNameInModule )
Removes the module part from the expression in the string.
Removes the module part from the expression in the string.
Examples:
1. demodulize("Fax_Job") => "Job"
1. demodulize("User") => "User"
|
public
|
#
tableize( mixed $className )
Creates the name of a table like Rails does for models to table names.
Creates the name of a table like Rails does for models to table names.
This method uses the pluralize() method on the last word in the string.
Examples:
1. tableize("RawScaledScorer") => "raw_scaled_scorers"
2. tableize("egg_and_ham") => "egg_and_hams"
3. tableize("fancyCategory") => "fancy_categories"
|
public
|
#
classify( mixed $tableName )
Creates a class name from a table name like Rails does for table names
to models.
Creates a class name from a table name like Rails does for table names
to models.
Examples:
1. classify("egg_and_hams") => "EggAndHam"
2. classify("post") => "Post"
|
public
|
#
foreignKey( mixed $className, mixed $separateClassNameAndIdWithUnderscore = true )
Creates a foreign key name from a class name.
Creates a foreign key name from a class name.
$separateClassNameAndIdWithUnderscore sets whether the method should put
'_' between the name and 'id'.
Examples:
1. foreignKey("Message") => "message_id"
2. foreignKey("Message", false) => "messageid"
3. foreignKey("Fax_Job") => "fax_job_id"
|
public
|
#
ordinalize( mixed $number )
Turns a number into an ordinal string used to denote the position in an
ordered sequence such as 1st, 2nd, 3rd, 4th.
Turns a number into an ordinal string used to denote the position in an
ordered sequence such as 1st, 2nd, 3rd, 4th.
Examples:
1. ordinalize(1) => "1st"
2. ordinalize(2) => "2nd"
3. ordinalize(1002) => "1002nd"
4. ordinalize(1003) => "1003rd"
|
public
|
#
clearCache( )
Clears the inflection cache.
Clears the inflection cache.
|
public
string
|
#
getCache( mixed $word, mixed $rule )
Retuns a cached inflection.
Retuns a cached inflection.
Returns
string | false
|
public
string
|
#
setCache( string $word, string $rule, string $value )
Caches an inflection.
Parameters
- $word
- The word being inflected.
- $rule
- The inflection rule.
- $value
- The inflected value of $word.
Returns
string The inflected value
|