本文整理匯總了PHP中Inflector::uncountable方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::uncountable方法的具體用法?PHP Inflector::uncountable怎麽用?PHP Inflector::uncountable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Inflector
的用法示例。
在下文中一共展示了Inflector::uncountable方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: uncountable
/**
* Checks if a word is defined as uncountable.
*
* @param string $str word to check
* @return boolean
*/
public static function uncountable($str)
{
if (self::$uncountable === NULL) {
// Cache uncountables
self::$uncountable = AetherDatabaseConfig::retrieve('inflector.uncountable');
// Make uncountables mirroed
self::$uncountable = array_combine(self::$uncountable, self::$uncountable);
}
return isset(self::$uncountable[strtolower($str)]);
}
示例2: plural
/**
* Makes a singular word plural.
*
* echo Inflector::plural('fish'); // "fish", uncountable
* echo Inflector::plural('cat'); // "cats"
*
* You can also provide the count to make inflection more intelligent.
* In this case, it will only return the plural value if the count is
* not one.
*
* echo Inflector::singular('cats', 3); // "cats"
*
* [!!] Special inflections are defined in `config/inflector.php`.
*
* @param string $str word to pluralize
* @param integer $count count of thing
*
* @return string
* @uses Inflector::uncountable
*/
public static function plural($str, $count = null)
{
// $count should always be a float
$count = $count === null ? 0.0 : (double) $count;
// Do nothing with singular
if ($count == 1) {
return $str;
}
// Remove garbage
$str = trim($str);
// Cache key name
$key = 'plural_' . $str . $count;
// Check uppercase
$is_uppercase = ctype_upper($str);
if (isset(Inflector::$cache[$key])) {
return Inflector::$cache[$key];
}
if (Inflector::uncountable($str)) {
return Inflector::$cache[$key] = $str;
}
if (empty(Inflector::$irregular)) {
// Cache irregular words
Inflector::$irregular = Kohana::$config->load('inflector')->irregular;
}
if (isset(Inflector::$irregular[$str])) {
$str = Inflector::$irregular[$str];
} elseif (in_array($str, Inflector::$irregular)) {
// Do nothing
} elseif (preg_match('/[sxz]$/', $str) or preg_match('/[^aeioudgkprt]h$/', $str)) {
$str .= 'es';
} elseif (preg_match('/[^aeiou]y$/', $str)) {
// Change "y" to "ies"
$str = substr_replace($str, 'ies', -1);
} else {
$str .= 's';
}
// Convert to uppercase if necessary
if ($is_uppercase) {
$str = strtoupper($str);
}
// Set the cache and return
return Inflector::$cache[$key] = $str;
}
示例3: plural
/**
* Makes a singular word plural.
*
* echo Inflector::plural('fish'); // "fish", uncountable
* echo Inflector::plural('cat'); // "cats"
*
* You can also provide the count to make inflection more intelligent.
* In this case, it will only return the plural value if the count is
* not one.
*
* echo Inflector::singular('cats', 3); // "cats"
*
* [!!] Special inflections are defined in `config/inflector.php`.
*
* @param string word to pluralize
* @return string
* @uses Inflector::uncountable
*/
public static function plural($str, $count = NULL)
{
// Remove garbage
$str = strtolower(trim($str));
if (is_string($count)) {
// Convert to integer when using a digit string
$count = (int) $count;
}
// Do nothing with singular
if ($count === 1) {
return $str;
}
// Cache key name
$key = 'plural_' . $str . $count;
if (isset(Inflector::$cache[$key])) {
return Inflector::$cache[$key];
}
if (Inflector::uncountable($str)) {
return Inflector::$cache[$key] = $str;
}
if (empty(Inflector::$irregular)) {
// Cache irregular words
Inflector::$irregular = Kohana::config('inflector')->irregular;
}
if (isset(Inflector::$irregular[$str])) {
$str = Inflector::$irregular[$str];
} elseif (preg_match('/[sxz]$/', $str) or preg_match('/[^aeioudgkprt]h$/', $str)) {
$str .= 'es';
} elseif (preg_match('/[^aeiou]y$/', $str)) {
// Change "y" to "ies"
$str = substr_replace($str, 'ies', -1);
} else {
$str .= 's';
}
// Set the cache and return
return Inflector::$cache[$key] = $str;
}
示例4: test_uncountable
/**
* Tests Inflector::uncountable
*
* @test
* @dataProvider provider_uncountable
* @param boolean $input Input for File::mime
* @param boolean $expected Output for File::mime
*/
public function test_uncountable($input, $expected)
{
$this->assertSame($expected, Inflector::uncountable($input));
}
示例5:
Inflector::singular('/([octop|vir])i$/i', '\\1us');
Inflector::singular('/(alias|status)es$/i', '\\1');
Inflector::singular('/^(ox)en/i', '\\1');
Inflector::singular('/(vert|ind)ices$/i', '\\1ex');
Inflector::singular('/(matr)ices$/i', '\\1ix');
Inflector::singular('/(quiz)zes$/i', '\\1');
Inflector::plural('/$/', 's');
Inflector::plural('/s$/i', 's');
Inflector::plural('/(ax|test)is$/i', '\\1es');
Inflector::plural('/(octop|vir)us$/i', '\\1i');
Inflector::plural('/(alias|status)$/i', '\\1es');
Inflector::plural('/(bu)s$/i', '\\1ses');
Inflector::plural('/(buffal|tomat)o$/i', '\\1oes');
Inflector::plural('/([ti])um$/i', '\\1a');
Inflector::plural('/sis$/i', 'ses');
Inflector::plural('/(?:([^f])fe|([lr])f)$/i', '\\1\\2ves');
Inflector::plural('/(hive)$/i', '\\1s');
Inflector::plural('/([^aeiouy]|qu)y$/i', '\\1ies');
Inflector::plural('/([^aeiouy]|qu)ies$/i', '\\1y');
Inflector::plural('/(x|ch|ss|sh)$/i', '\\1es');
Inflector::plural('/(matr|vert|ind)ix|ex$/i', '\\1ices');
Inflector::plural('/([m|l])ouse$/i', '\\1ice');
Inflector::plural('/^(ox)$/i', '\\1en');
Inflector::plural('/(quiz)$/i', '\\1zes');
Inflector::irregular('person', 'people');
Inflector::irregular('man', 'men');
Inflector::irregular('child', 'children');
Inflector::irregular('sex', 'sexes');
Inflector::irregular('move', 'moves');
Inflector::uncountable(array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'deer', 'elk', 'cattle'));
示例6:
Inflector::singular('/([ti])a$/i', '\\1um');
Inflector::singular('/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i', '\\1\\2sis');
Inflector::singular('/(^analy)ses$/i', '\\1sis');
Inflector::singular('/([^f])ves$/i', '\\1fe');
Inflector::singular('/(hive)s$/i', '\\1');
Inflector::singular('/(tive)s$/i', '\\1');
Inflector::singular('/([lr])ves$/i', '\\1f');
Inflector::singular('/([^aeiouy]|qu)ies$/i', '\\1y');
Inflector::singular('/(s)eries$/i', '\\1eries');
Inflector::singular('/(m)ovies$/i', '\\1ovie');
Inflector::singular('/(x|ch|ss|sh)es$/i', '\\1');
Inflector::singular('/([m|l])ice$/i', '\\1ouse');
Inflector::singular('/(bus)es$/i', '\\1');
Inflector::singular('/(o)es$/i', '\\1');
Inflector::singular('/(shoe)s$/i', '\\1');
Inflector::singular('/(cris|ax|test)es$/i', '\\1is');
Inflector::singular('/(octop|vir)i$/i', '\\1us');
Inflector::singular('/(alias|status)es$/i', '\\1');
Inflector::singular('/^(ox)en/i', '\\1');
Inflector::singular('/(vert|ind)ices$/i', '\\1ex');
Inflector::singular('/(matr)ices$/i', '\\1ix');
Inflector::singular('/(quiz)zes$/i', '\\1');
Inflector::singular('/(database)s$/i', '\\1');
Inflector::irregular('person', 'people');
Inflector::irregular('man', 'men');
Inflector::irregular('child', 'children');
Inflector::irregular('sex', 'sexes');
Inflector::irregular('move', 'moves');
Inflector::irregular('cow', 'cattle');
Inflector::uncountable(array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans'));