Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (27 sloc) 735 Bytes
<?php
declare(strict_types=1);
namespace Doctrine\Inflector;
use Doctrine\Inflector\Rules\Ruleset;
class RulesetInflector implements WordInflector
{
/** @var Ruleset */
private $ruleset;
public function __construct(Ruleset $ruleset)
{
$this->ruleset = $ruleset;
}
public function inflect(string $word) : string
{
if ($word === '') {
return '';
}
if ($this->ruleset->getUninflected()->matches($word)) {
return $word;
}
$inflected = $this->ruleset->getIrregular()->inflect($word);
if ($inflected !== $word) {
return $inflected;
}
return $this->ruleset->getRegular()->inflect($word);
}
}
You can’t perform that action at this time.