Some of this code was written by Flinn Mueller.

package Fuel
category Core
copyright Flinn Mueller
link http://docs.fuelphp.com/classes/inlector.html

 Methods

Load any localized rules on first load

_init() 

Translate string to 7-bit ASCII Only works with UTF-8.

ascii(string $str, bool $allow_non_ascii) : string

Parameters

$str

string

string to translate

$allow_non_ascii

bool

whether to remove non ascii

Returns

stringtranslated string

Takes a string that has words separated by underscores and turns it into a CamelCased string.

camelize(string $underscored_word) : string

Parameters

$underscored_word

string

the underscored word

Returns

stringthe CamelCased version of $underscored_word

Takes a table name and creates the class name.

classify(string $name, bool $force_singular) : string

Parameters

$name

string

the table name

$force_singular

bool

whether to singularize the table name or not

Returns

stringthe class name

Takes the class name out of a modulized string.

demodulize(string $class_name_in_module) : string

Parameters

$class_name_in_module

string

the modulized class

Returns

stringthe string without the class name

Takes the namespace off the given class name.

denamespace(string $class_name) : string

Parameters

$class_name

string

the class name

Returns

stringthe string without the namespace

Gets the foreign key for a given class.

foreign_key(string $class_name, bool $use_underscore) : string

Parameters

$class_name

string

the class name

$use_underscore

bool

whether to use an underscore or not

Returns

stringthe foreign key

Converts your text to a URL-friendly title so it can be used in the URL.

friendly_title(string $str, string $sep, bool $lowercase, bool $allow_non_ascii) : string

Only works with UTF8 input and and only outputs 7 bit ASCII characters.

Parameters

$str

string

the text

$sep

string

the separator

$lowercase

bool

whether to convert to lowercase

$allow_non_ascii

bool

whether to allow non ascii

Returns

stringthe new title

Returns the namespace of the given class name.

get_namespace(string $class_name) : string

Parameters

$class_name

string

the class name

Returns

stringthe string without the namespace

Turns an underscore or dash separated word and turns it into a human looking string.

humanize(string $str, string $sep, bool $lowercase) : string

Parameters

$str

string

the word

$sep

string

the separator (either _ or -)

$lowercase

bool

lowercase string and upper case first

Returns

stringthe human version of given string

Checks if the given word has a plural version.

is_countable(string $word) : bool

Parameters

$word

string

the word to check

Returns

boolif the word is countable

Load any localized rulesets based on the current language configuration If not exists, the current rules remain active

load_rules() 

Add order suffix to numbers ex.

ordinalize(int $number) : string

1st 2nd 3rd 4th 5th

link http://snipplr.com/view/4627/a-function-to-add-a-prefix-to-numbers-ex-1st-2nd-3rd-4th-5th/

Parameters

$number

int

the number to ordinalize

Returns

stringthe ordinalized version of $number

Gets the plural version of the given word

pluralize(string $word, int $count) : string

Parameters

$word

string

the word to pluralize

$count

int

number of instances

Returns

stringthe plural version of $word

Gets the singular version of the given word

singularize(string $word) : string

Parameters

$word

string

the word to singularize

Returns

stringthe singular version of $word

Takes a class name and determines the table name.

tableize(string $class_name) : string

The table name is a pluralized version of the class name.

Parameters

$class_name

string

the table name

Returns

stringthe table name

Takes a CamelCased string and returns an underscore separated version.

underscore(string $camel_cased_word) : string

Parameters

$camel_cased_word

string

the CamelCased word

Returns

stringan underscore separated version of $camel_cased_word

Takes an underscored classname and uppercases all letters after the underscores.

words_to_upper(string $class, string $sep) : string

Parameters

$class

string

classname

$sep

string

separator

Returns

string

 Properties

 

<p>default list of iregular plural words, in English</p>

$plural_rules : array

 

<p>default list of iregular singular words, in English</p>

$singular_rules : array

 

<p>default list of uncountable words, in English</p>

$uncountable_words : array