2021-05-10 00:23:30 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare (strict_types=1);
|
|
|
|
namespace RectorPrefix20210510\Doctrine\Inflector;
|
|
|
|
|
|
|
|
use RectorPrefix20210510\Doctrine\Inflector\Rules\English;
|
|
|
|
use RectorPrefix20210510\Doctrine\Inflector\Rules\French;
|
|
|
|
use RectorPrefix20210510\Doctrine\Inflector\Rules\NorwegianBokmal;
|
|
|
|
use RectorPrefix20210510\Doctrine\Inflector\Rules\Portuguese;
|
|
|
|
use RectorPrefix20210510\Doctrine\Inflector\Rules\Spanish;
|
|
|
|
use RectorPrefix20210510\Doctrine\Inflector\Rules\Turkish;
|
|
|
|
use InvalidArgumentException;
|
|
|
|
use function sprintf;
|
|
|
|
final class InflectorFactory
|
|
|
|
{
|
2021-05-10 22:10:16 +00:00
|
|
|
public static function create() : LanguageInflectorFactory
|
2021-05-10 00:23:30 +00:00
|
|
|
{
|
2021-05-10 22:10:16 +00:00
|
|
|
return self::createForLanguage(Language::ENGLISH);
|
2021-05-10 00:23:30 +00:00
|
|
|
}
|
2021-05-10 22:10:16 +00:00
|
|
|
public static function createForLanguage(string $language) : LanguageInflectorFactory
|
2021-05-10 00:23:30 +00:00
|
|
|
{
|
|
|
|
switch ($language) {
|
2021-05-10 22:10:16 +00:00
|
|
|
case Language::ENGLISH:
|
|
|
|
return new English\InflectorFactory();
|
|
|
|
case Language::FRENCH:
|
|
|
|
return new French\InflectorFactory();
|
|
|
|
case Language::NORWEGIAN_BOKMAL:
|
|
|
|
return new NorwegianBokmal\InflectorFactory();
|
|
|
|
case Language::PORTUGUESE:
|
|
|
|
return new Portuguese\InflectorFactory();
|
|
|
|
case Language::SPANISH:
|
|
|
|
return new Spanish\InflectorFactory();
|
|
|
|
case Language::TURKISH:
|
|
|
|
return new Turkish\InflectorFactory();
|
2021-05-10 00:23:30 +00:00
|
|
|
default:
|
2021-05-10 22:10:16 +00:00
|
|
|
throw new InvalidArgumentException(sprintf('Language "%s" is not supported.', $language));
|
2021-05-10 00:23:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|