PHP Class FOF30\Inflector\Inflector

Afficher le fichier Open project: akeeba/fof

Protected Properties

Свойство Type Description
$cache array Cache of pluralized and singularized nouns.
$rules array Rules for pluralizing and singularizing of nouns.

Méthodes publiques

Méthode Description
addWord ( string $singular, string $plural ) : void Add a word to the cache, useful to make exceptions or to add words in other languages.
camelize ( string $word ) : string Returns given word as CamelCased.
deleteCache ( )
explode ( string $word ) : array Convert any "CamelCased" word into an array of strings
getPart ( string $string, integer $index, string $default = null ) : string Gets a part of a CamelCased word by index.
humanize ( string $word ) : string Returns a human-readable string from $word.
implode ( array $words ) : string Convert an array of strings into a "CamelCased" word.
isPlural ( string $string ) : boolean Check to see if an Enlish word is plural.
isSingular ( string $string ) : boolean Check to see if an English word is singular
pluralize ( string $word ) : string Singular English word to plural.
singularize ( string $word ) : string Plural English word to singular.
underscore ( string $word ) : string Converts a word "into_it_s_underscored_version"
variablize ( string $string ) : string Returns camelBacked version of a string. Same as camelize but first char is lowercased.

Method Details

addWord() public méthode

Add a word to the cache, useful to make exceptions or to add words in other languages.
public addWord ( string $singular, string $plural ) : void
$singular string word.
$plural string word.
Résultat void

camelize() public méthode

Converts a word like "foo_bar" or "foo bar" to "FooBar". It will remove non alphanumeric characters from the word, so "who's online" will be converted to "WhoSOnline"
public camelize ( string $word ) : string
$word string Word to convert to camel case.
Résultat string UpperCamelCasedWord

deleteCache() public méthode

public deleteCache ( )

explode() public méthode

Returns an array of strings each of which is a substring of string formed by splitting it at the camelcased letters.
public explode ( string $word ) : array
$word string Word to explode
Résultat array Array of strings

getPart() public méthode

Use a negative index to start at the last part of the word (-1 is the last part)
public getPart ( string $string, integer $index, string $default = null ) : string
$string string Word
$index integer Index of the part
$default string Default value
Résultat string

humanize() public méthode

Returns a human-readable string from $word, by replacing underscores with a space, and by upper-casing the initial character by default.
public humanize ( string $word ) : string
$word string String to "humanize"
Résultat string Human-readable word

implode() public méthode

Convert an array of strings into a "CamelCased" word.
public implode ( array $words ) : string
$words array Array to implode
Résultat string UpperCamelCasedWord

isPlural() public méthode

Check to see if an Enlish word is plural.
public isPlural ( string $string ) : boolean
$string string String to be checked.
Résultat boolean

isSingular() public méthode

Check to see if an English word is singular
public isSingular ( string $string ) : boolean
$string string The word to check
Résultat boolean

pluralize() public méthode

Singular English word to plural.
public pluralize ( string $word ) : string
$word string word to pluralize.
Résultat string Plural noun.

singularize() public méthode

Plural English word to singular.
public singularize ( string $word ) : string
$word string Word to singularize.
Résultat string Singular noun.

underscore() public méthode

Convert any "CamelCased" or "ordinary Word" into an "underscored_word".
public underscore ( string $word ) : string
$word string Word to underscore
Résultat string Underscored word

variablize() public méthode

Returns camelBacked version of a string. Same as camelize but first char is lowercased.
See also: camelize
public variablize ( string $string ) : string
$string string String to be camelBacked.
Résultat string

Property Details

$cache protected_oe property

Cache of pluralized and singularized nouns.
protected array $cache
Résultat array

$rules protected_oe property

Rules for pluralizing and singularizing of nouns.
protected array $rules
Résultat array