\VivialConnect\CommonInflector

Summary

Methods
Properties
Constants
singularize()
pluralize()
isSingular()
isPlural()
isCountable()
isIrregular()
ordinalize()
camelize()
dasherize()
titleize()
underscore()
humanize()
demodulize()
tableize()
classify()
foreignKey()
intersectEntity()
$singulars
$plurals
$irregular
$uncountable
$railsStyle
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$singulars

$singulars : array

List of singular nouns as rule => replacement.

Type

array

$plurals

$plurals : array

List of plural nouns as rule => replacement.

Type

array

$irregular

$irregular : array

List of irregular nouns as rule => replacement.

Type

array

$uncountable

$uncountable : array

List of uncountable nouns.

å

Type

array

$railsStyle

$railsStyle : boolean

Type

boolean — use Ruby on Rails ActiveRecord naming conventions?

Methods

singularize()

singularize(string  $word) : string

The reverse of pluralize, returns the singular form of a word.

Parameters

string $word

The word to singularize.

Returns

string

pluralize()

pluralize(string  $word) : string

Returns the plural form of the word.

Parameters

string $word

The word to pluralize.

Returns

string

isSingular()

isSingular(string  $word) : boolean

Returns true if the given string is a singular noun, false otherwise.

Parameters

string $word

The word to check.

Returns

boolean

isPlural()

isPlural(string  $word) : boolean

Returns true if the given string is a plural noun, false otherwise.

Parameters

string $word

The word to check.

Returns

boolean

isCountable()

isCountable(string  $word) : boolean

Returns true if the given string is a countable noun, false otherwise.

Parameters

string $word

The word to check.

Returns

boolean

isIrregular()

isIrregular(string  $word) : boolean

Returns true if the given string is an irregular noun, false otherwise.

Parameters

string $word

The word to check.

Returns

boolean

ordinalize()

ordinalize(integer  $number) : string

Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.

Parameters

integer $number

The number to ordinalize.

Returns

string

camelize()

camelize(string  $word, boolean  $firstUpper = true) : string

By default, camelize() converts strings to UpperCamelCase. If the second argument is set to false then camelize() produces lowerCamelCase. camelize() will also convert '/' to '\' which is useful for converting paths to namespaces.

Parameters

string $word

Lower case and underscored word.

boolean $firstUpper

First letter in uppercase?

Returns

string

dasherize()

dasherize(string  $word) : string

Replaces underscores with dashes in the string.

Parameters

string $word

Underscored word.

Returns

string

titleize()

titleize(string  $word) : string

Capitalizes all the words and replaces some characters in the string to create a nicer looking title. Titleize() is meant for creating pretty output.

Parameters

string $word

Underscored word.

Returns

string

underscore()

underscore(string  $word) : string

The reverse of camelize(). Makes an underscored form from the expression in the string. Changes '::' to '/' to convert namespaces to paths.

Parameters

string $word

Camel cased word.

Returns

string

humanize()

humanize(string  $word) : string

Capitalizes the first word and turns underscores into spaces and strips _id.

Like titleize(), this is meant for creating pretty output.

Parameters

string $word

Lower case and underscored word.

Returns

string

demodulize()

demodulize(string  $class) : string

Removes the namespace part from the expression in the string.

Parameters

string $class

Class name in namespace.

Returns

string

tableize()

tableize(string  $class) : string

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.

Parameters

string $class

Class name.

Returns

string

classify()

classify(string  $table) : string

Create a class name from a plural table name like Rails does for table names to models. Note that this returns a string and not a Class.

To convert to an actual class follow classify() with constantize().

Parameters

string $table

Table name.

Returns

string

foreignKey()

foreignKey(string  $class) : string

Creates a foreign key name from a class name. Second parameter sets whether the method should put '_' between the name and 'id'/'Id'.

Parameters

string $class

Class name.

Returns

string

intersectEntity()

intersectEntity(string  $local, string  $referenced) : string

Create the name of an intersect entity of M:N relation of the given tables.

Parameters

string $local

Local table name.

string $referenced

Referenced table name.

Returns

string