public static function Inflector::pluralize in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/doctrine/inflector/lib/Doctrine/Common/Inflector/Inflector.php \Doctrine\Common\Inflector\Inflector::pluralize()
Returns a word in plural form.
Parameters
string $word The word in singular form.:
Return value
string The word in plural form.
4 calls to Inflector::pluralize()
- InflectorTest::testCustomPluralRule in vendor/
doctrine/ inflector/ tests/ Doctrine/ Tests/ Common/ Inflector/ InflectorTest.php - testCustomPluralRule method
- InflectorTest::testCustomRuleWithReset in vendor/
doctrine/ inflector/ tests/ Doctrine/ Tests/ Common/ Inflector/ InflectorTest.php - Test resetting inflection rules.
- InflectorTest::testInflectingPlurals in vendor/
doctrine/ inflector/ tests/ Doctrine/ Tests/ Common/ Inflector/ InflectorTest.php - testInflectingPlurals method
- InflectorTest::testRulesClearsCaches in vendor/
doctrine/ inflector/ tests/ Doctrine/ Tests/ Common/ Inflector/ InflectorTest.php - test that setting new rules clears the inflector caches.
File
- vendor/
doctrine/ inflector/ lib/ Doctrine/ Common/ Inflector/ Inflector.php, line 319
Class
- Inflector
- Doctrine inflector has static methods for inflecting text.
Namespace
Doctrine\Common\InflectorCode
public static function pluralize($word) {
if (isset(self::$cache['pluralize'][$word])) {
return self::$cache['pluralize'][$word];
}
if (!isset(self::$plural['merged']['irregular'])) {
self::$plural['merged']['irregular'] = self::$plural['irregular'];
}
if (!isset(self::$plural['merged']['uninflected'])) {
self::$plural['merged']['uninflected'] = array_merge(self::$plural['uninflected'], self::$uninflected);
}
if (!isset(self::$plural['cacheUninflected']) || !isset(self::$plural['cacheIrregular'])) {
self::$plural['cacheUninflected'] = '(?:' . implode('|', self::$plural['merged']['uninflected']) . ')';
self::$plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$plural['merged']['irregular'])) . ')';
}
if (preg_match('/(.*)\\b(' . self::$plural['cacheIrregular'] . ')$/i', $word, $regs)) {
self::$cache['pluralize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$plural['merged']['irregular'][strtolower($regs[2])], 1);
return self::$cache['pluralize'][$word];
}
if (preg_match('/^(' . self::$plural['cacheUninflected'] . ')$/i', $word, $regs)) {
self::$cache['pluralize'][$word] = $word;
return $word;
}
foreach (self::$plural['rules'] as $rule => $replacement) {
if (preg_match($rule, $word)) {
self::$cache['pluralize'][$word] = preg_replace($rule, $replacement, $word);
return self::$cache['pluralize'][$word];
}
}
}