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\Irregular;
use Doctrine\Inflector\Rules\Plural;
use Doctrine\Inflector\Rules\Ruleset;
use Doctrine\Inflector\Rules\Transformations;
use Doctrine\Inflector\Rules\Uninflected;
final class PluralizerFactory
{
/** @var Transformations */
private $transformations;
/** @var Uninflected */
private $uninflected;
/** @var Irregular */
private $irregular;
public function withTransformations(Transformations $transformations) : self
$this->transformations = $transformations;
return $this;
}
public function withUninflected(Uninflected $uninflected) : self
$this->uninflected = $uninflected;
public function withIrregular(Irregular $irregular) : self
$this->irregular = $irregular;
public function build() : Ruleset
$transformations = $this->transformations ?? new Transformations(...Plural::getDefaultTransformations());
$uninflected = $this->uninflected ?? new Uninflected(...Plural::getUninflectedWords());
$irregular = $this->irregular ?? new Irregular(...Plural::getIrregularRules());
$pluralUninflected = new Uninflected(...(static function () use ($uninflected) : iterable {
yield from $uninflected->getWords();
yield from Uninflected::getDefaultWords();
})());
return new Ruleset($transformations, $pluralUninflected, $irregular);