FOF30\Inflector\Inflector::pluralize PHP Метод

pluralize() публичный Метод

Singular English word to plural.
public pluralize ( string $word ) : string
$word string word to pluralize.
Результат string Plural noun.
    public function pluralize($word)
    {
        // Get the cached noun of it exists
        if (isset($this->cache['pluralized'][$word])) {
            return $this->cache['pluralized'][$word];
        }
        // Check if the noun is already in plural form, i.e. in the singularized cache
        if (isset($this->cache['singularized'][$word])) {
            return $word;
        }
        // Create the plural noun
        if (in_array($word, $this->rules['uncountable'])) {
            $_cache['pluralized'][$word] = $word;
            return $word;
        }
        foreach ($this->rules['pluralization'] as $regexp => $replacement) {
            $matches = null;
            $plural = preg_replace($regexp, $replacement, $word, -1, $matches);
            if ($matches > 0) {
                $_cache['pluralized'][$word] = $plural;
                return $plural;
            }
        }
        return $word;
    }