Inflector クラス
The Inflector class allows you to transforms words from singular to plural, class names to table names, modularized class names to ones without, and class names to foreign keys.
ascii($str)
The ascii method allows you to translate a string to a 7-bit ASCII string. This method only works with UTF-8.
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$str |
必須 |
The string to translate. |
|
返り値 |
string |
例 |
echo Inflector::ascii('Inglés'); // returns Ingles
|
camelize($underscored_word)
The camelize method allows you to convert a string with words separated by underscores into a CamelCased string.
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$underscored_word |
必須 |
The underscored word. |
|
返り値 |
string |
例 |
echo Inflector::camelize('apples_and_oranges'); // returns ApplesAndOranges
|
words_to_upper($class)
The words_to_upper method uppercases the first letter of each word in a classname with
the words separated by underscores.
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$class |
必須 |
The classname. |
$sep |
_ |
The separator |
|
返り値 |
string |
例 |
echo Inflector::words_to_upper('fuel_users'); // returns Fuel_Users
echo Inflector::words_to_upper('module::method', '::'); // returns Module::Method
|
classify($table_name)
The classify method allows you to convert a table name to a class name.
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$table_name |
必須 |
The table name. |
$singularize |
true
|
Whether the $tablename is singularized before its words are uppercased. |
|
返り値 |
string |
例 |
echo Inflector::classify('fuel_users'); // returns Fuel_User
|
demodulize($class_name_in_module)
The demodulize method allows you to take the class name out of a modulized string.
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$class_name_in_module |
必須 |
The modulized class. |
|
返り値 |
string |
例 |
echo Inflector::demodulize('Uri::main()'); // returns main()
|
denamespace($class_name)
The denamespace method allows you to take the namespace off the given class name.
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$class_name |
必須 |
The class name. |
|
返り値 |
string |
例 |
echo Inflector::denamespace('Fuel\\Core\\Config'); // returns Config
|
get_namespace($class_name)
The get_namespace method returns the namespace of the given class name..
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$class_name |
必須 |
The class name. |
|
返り値 |
string, the namespace |
例 |
echo Inflector::get_namespace('Fuel\\Core\\Config'); // returns Fuel\Core\
|
foreign_key($class_name, $use_underscore = true)
The foreign_key method allows you to get the foreign key for a given class.
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$class_name |
必須 |
The class name. |
$use_underscore |
true
|
Whether to use an underscore or not. |
|
返り値 |
string |
例 |
echo Inflector::foreign_key('Inflector'); // returns inflector_id
echo Inflector::foreign_key('Inflector', false); // returns inflectorid
|
friendly_title($str, $sep = '-', $lowercase = false)
The friendly_title method allows you to convert your text to a URL-friendly title so that it can be used in the URL. It only works with UTF-8 input and outputs 7 bit ASCII characters.
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$str |
必須 |
The text to convert. |
$sep |
-
|
The separator (either - or _) |
$lowercase |
false
|
Whether to use lowercase or not. |
|
返り値 |
string |
例 |
echo Inflector::friendly_title('Fuel is a community driven PHP 5 web framework.', '-', true);
// returns fuel-is-a-community-driven-php-5-web-framework
|
humanize($lower_case_and_underscored_word)
The humanize method allows you to turn an underscore separated word and turns it into a human looking string.
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$lower_case_and_underscored_word |
必須 |
The word to convert. |
|
返り値 |
string |
例 |
echo Inflector::humanize('apples_and_oranges'); // returns Apples and oranges
|
is_countable($word)
The is_countable method allows you check if the given word has a plural version.
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$word |
必須 |
The word to check. |
|
返り値 |
boolean |
例 |
echo Inflector::is_countable('fish'); // returns false
echo Inflector::is_countable('apple'); // returns true
|
pluralize($word)
The pluralize method allows you get the plural version of the given word.
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$word |
必須 |
The word you want to pluralize. |
|
返り値 |
string |
例 |
echo Inflector::pluralize('apple'); // returns apples
|
ordinalize($number)
The ordinalize method allows you to add english language order number suffixes.
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$number |
必須 |
The number you want to ordinalize. |
|
返り値 |
string |
例 |
echo Inflector::ordinalize(2); // returns 2nd
|
singularize($word)
The singularize method allows you get the singular version of the given word.
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$word |
必須 |
The word you want to singularize. |
|
返り値 |
string |
例 |
echo Inflector::singularize('apples'); // returns apple
|
tableize($class_name)
The tableize method allows you to convert a class name to a table name.
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$class_name |
必須 |
The class name. |
|
返り値 |
string |
例 |
echo Inflector::tableize('FuelUser'); // returns fuel_users
|
underscore($camel_cased_word)
The underscore method allows you to convert a CamelCased string into an underscore separated string.
Static |
Yes |
パラメータ |
パラメータ |
規定値 |
説明 |
$camel_cased_word |
必須 |
The CamelCased word. |
|
返り値 |
string |
例 |
echo Inflector::underscore('ApplesAndOranges'); // returns apples_and_oranges
|