Documentation

Inflector extends DataObject
in package
implements InflectorInterface

Language inflection such as pluralisation.

Includes utilities for converting between snake/camel/kebab string formats.

DO NOT use this for i18n. This is strictly for inflection of INTERNAL CODE UTILITIES.

Table of Contents

Interfaces

InflectorInterface
Language inflection (in English) for pluralisation.

Properties

$irregular  : array<string, string>
$uncountable  : array<string|int, string>
$_cache  : array<string|int, mixed>

Methods

__construct()  : mixed
camelize()  : string
Makes a phrase camel case.
humanize()  : string
Makes a phrase human-readable from any form (kebab, underscore, camel).
kebab()  : string
Makes a phrase kebab-case.
plural()  : string
Makes a singular word plural.
singular()  : string
Makes a plural word singular.
uncountable()  : bool
Checks if a word is defined as uncountable.
underscore()  : string
Makes a phrase underscored.
update()  : void
Update the object with a new configuration.
_plural()  : string
Makes a singular word plural.
_singular()  : string
Makes a plural word singular.

Properties

$irregular

public array<string, string> $irregular = []

$uncountable

public array<string|int, string> $uncountable = []

$_cache

protected array<string|int, mixed> $_cache = []

Methods

__construct()

public __construct([mixed $config = null ]) : mixed
Parameters
$config : mixed = null
Tags
inheritdoc

camelize()

Makes a phrase camel case.

public static camelize(string $phrase[, bool $first = true ]) : string
Parameters
$phrase : string
$first : bool = true

Upper case the first letter

Return values
string

humanize()

Makes a phrase human-readable from any form (kebab, underscore, camel).

public static humanize(string $phrase) : string
Parameters
$phrase : string
Return values
string

kebab()

Makes a phrase kebab-case.

public static kebab(string $phrase) : string
Parameters
$phrase : string
Return values
string

plural()

Makes a singular word plural.

public plural(string $word[, int $count = 0 ]) : string
Parameters
$word : string
$count : int = 0
Return values
string

singular()

Makes a plural word singular.

public singular(string $word[, int $count = 1 ]) : string
Parameters
$word : string
$count : int = 1

number of things

Return values
string

uncountable()

Checks if a word is defined as uncountable.

public uncountable(string $word) : bool
Parameters
$word : string
Return values
bool

underscore()

Makes a phrase underscored.

public static underscore(string $phrase) : string
Parameters
$phrase : string
Return values
string

update()

Update the object with a new configuration.

public update(iterable<string|int, mixed> $config) : void
Parameters
$config : iterable<string|int, mixed>
Tags
inheritdoc

_plural()

Makes a singular word plural.

protected _plural(string $word[, int $count = 0 ]) : string
Parameters
$word : string
$count : int = 0
Return values
string

_singular()

Makes a plural word singular.

protected _singular(string $word[, int $count = 1 ]) : string
Parameters
$word : string
$count : int = 1

number of things

Return values
string
On this page

Search results