for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Doctrine\Inflector;
use Doctrine\Inflector\Rules\Ruleset;
class RulesetInflector
{
/** @var Ruleset */
private $ruleset;
/** @var string[] */
private $wordInflectionCache = [];
public function __construct(Ruleset $ruleset)
$this->ruleset = $ruleset;
}
public function inflect(string $word) : string
if (! isset($this->wordInflectionCache[$word])) {
$this->wordInflectionCache[$word] = $this->doInflect($word);
return $this->wordInflectionCache[$word];
private function doInflect(string $word) : string
$inflected = $this->ruleset->getIrregular()->inflect($word);
if ($inflected !== null) {
return $inflected;
if ($this->ruleset->getUninflected()->isUninflected($word)) {
return $word;
return $this->ruleset->getRules()->inflect($word);