2017 © Pedro Peláez
 

library inflector

Inflector pluralizes and singularizes English nouns. It also contains some other useful methods.

image

gevman/inflector

Inflector pluralizes and singularizes English nouns. It also contains some other useful methods.

  • Monday, February 19, 2018
  • by gevorgmansuryan
  • Repository
  • 1 Watchers
  • 5 Stars
  • 33 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Inflector pluralizes and singularizes English nouns. It also contains some other useful methods.

string Inflector::pluralize(string $word)

Converts a word to its plural form. Note that this is for English only!, (*1)

For example, 'apple' will become 'apples', and 'child' will become 'children'. -param string $word the word to be pluralized, (*2)

string Inflector::singularize(string $word)

Returns the singular of the $word. - param string $word the english word to singularize, (*3)

string Inflector::titleize(string $word [, bool $ucAll = false])

Converts an underscored or CamelCase word into a English sentence. - param string $words - param $ucAll whether to set all words to uppercase, (*4)

string Inflector::camelize(string $word)

Converts a word like "send_email" to "SendEmail". It will remove non alphanumeric character from the word, so "who's online" will be converted to "WhoSOnline". - param string $word the word to CamelCase, (*5)

string Inflector::camel2words(string $word [, bool $ucwords = false])

Converts a CamelCase name into space-separated words., (*6)

For example, 'PostTag' will be converted to 'Post Tag'. - param string $name the string to be converted - param bool $ucwords whether to capitalize the first letter in each word - param $ucwords whether to capitalize the first letter in each word., (*7)

string Inflector::camel2id(string $name [, string $separator = '-' [, bool $strict = false]])

Converts a CamelCase name into an ID in lowercase. Words in the ID may be concatenated using the specified character (defaults to '-')., (*8)

For example, 'PostTag' will be converted to 'post-tag'. - param string $name the string to be converted - param string $separator the character used to concatenate the words in the ID - param bool|string $strict whether to insert a separator between two consecutive uppercase chars, defaults to false, (*9)

string Inflector::id2camel(string $id [, string $separator = '-'])

Converts an ID into a CamelCase name. Words in the ID separated by $separator (defaults to '-') will be concatenated into a CamelCase name., (*10)

For example, 'post-tag' is converted to 'PostTag'., (*11)

  • param string $id the ID to be converted
  • param string $separator the character used to separate the words in the ID
string Inflector::underscore(string $words)

Converts any "CamelCased" into an "underscored_word". - param string $words the word(s) to underscore, (*12)

string Inflector::humanize(string $word [, bool $ucAll = false])

Returns a human-readable string from $word. - param string $word the string to humanize - param bool $ucAll whether to set all words to uppercase or not, (*13)

string Inflector::variablize(string $word)

Same as camelize but first char is in lowercase. Converts a word like "send_email" to "sendEmail". It will remove non alphanumeric character from the word, so "who's online" will be converted to "whoSOnline". - param string $word to lowerCamelCase, (*14)

string Inflector::tableize(string $className)

Converts a class name to its table name (pluralized) naming conventions., (*15)

For example, converts "Person" to "people". - param string $className the class name for getting related table_name, (*16)

string Inflector::slug(string $name [, string $replacement = '-' [, bool $lowercase = true]])

Returns a string with all spaces converted to given replacement, non word characters removed and the rest of characters transliterated., (*17)

If intl extension isn't available uses fallback that converts latin characters only and removes the rest. You may customize characters map via $transliteration property of the helper. - param string $string An arbitrary string to convert - param string $replacement The replacement to use for spaces - param bool $lowercase whether to return the string in lowercase or not. Defaults to true., (*18)

string Inflector::transliterate(string $string [, string|\Transliterator $transliterator = null])

Returns transliterated version of a string., (*19)

If intl extension isn't available uses fallback that converts latin characters only and removes the rest. You may customize characters map via $transliteration property of the helper. - param string $string input string - param string|\Transliterator $transliterator either a [[\Transliterator]] or a string from which a [[\Transliterator]] can be built., (*20)

string Inflector::classify(string $tableName)

Converts a table name to its class name., (*21)

For example, converts "people" to "Person". - param string $tableName, (*22)

string Inflector::ordinalize(int $number)

Converts number to its ordinal English form. For example, converts 13 to 13th, 2 to 2nd ... - param int $number the number to get its ordinal value, (*23)

string Inflector::sentence(array $words [, $twoWordsConnector = ' and ' [, $lastWordConnector = null [, $connector = ', ']]])

Converts a list of words into a sentence., (*24)

Special treatment is done for the last few words. For example,, (*25)

$words = ['Spain', 'France'];
echo Inflector::sentence($words);
// output: Spain and France

$words = ['Spain', 'France', 'Italy'];
echo Inflector::sentence($words);
// output: Spain, France and Italy

$words = ['Spain', 'France', 'Italy'];
echo Inflector::sentence($words, ' & ');
// output: Spain, France & Italy
  • param array $words the words to be converted into an string
  • param string $twoWordsConnector the string connecting words when there are only two
  • param string $lastWordConnector the string connecting the last two words. If this is null, it will take the value of $twoWordsConnector.
  • param string $connector the string connecting words other than those connected by $lastWordConnector and $twoWordsConnector

The Versions

19/02 2018

dev-master

9999999-dev

Inflector pluralizes and singularizes English nouns. It also contains some other useful methods.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4

 

by Gevorg Mansuryan

19/02 2018

1.0

1.0.0.0

Inflector pluralizes and singularizes English nouns. It also contains some other useful methods.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4

 

by Gevorg Mansuryan