本文整理汇总了PHP中Faker\Generator::getProviders方法的典型用法代码示例。如果您正苦于以下问题:PHP Generator::getProviders方法的具体用法?PHP Generator::getProviders怎么用?PHP Generator::getProviders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Faker\Generator
的用法示例。
在下文中一共展示了Generator::getProviders方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createOrReturnExistingInstance
/**
* @param string $locale e.g. 'fr_FR', 'en_US'
*
* @return FakerGenerator
*/
public function createOrReturnExistingInstance(string $locale) : FakerGenerator
{
if (array_key_exists($locale, $this->generators)) {
return $this->generators[$locale];
}
$instance = FakerFactory::create($locale);
$generatorProviders = $this->generator->getProviders();
foreach ($generatorProviders as $provider) {
if (1 !== preg_match('/^Faker\\\\Provider.*/', get_class($provider))) {
$instance->addProvider($provider);
}
}
return $this->generators[$locale] = $instance;
}
示例2: assertGeneratorLocaleIs
private function assertGeneratorLocaleIs(string $locale, FakerGenerator $generator)
{
$providers = $generator->getProviders();
$regex = sprintf('/^Faker\\\\Provider\\\\%s\\\\.*/', $locale);
foreach ($providers as $provider) {
if (preg_match($regex, get_class($provider))) {
return;
}
}
throw new \Exception(sprintf('Generator has not been initialised with the locale "%s".', $locale));
}
示例3: assertHasAliceProvider
private function assertHasAliceProvider(FakerGenerator $generator)
{
$providers = $generator->getProviders();
foreach ($providers as $provider) {
if ($provider instanceof AliceProvider) {
return;
}
}
throw new \Exception(sprintf('Generator does not have the provider "%s".', AliceProvider::class));
}
示例4: testGenerator
public function testGenerator()
{
$this->assertSame('Hautelook\\AliceBundle\\Tests\\SymfonyApp\\TestBundle\\DataFixtures\\Faker\\Provider\\FooProvider', get_class($this->faker->getProviders()[0]), 'Expected custom Faker provider to be registered.');
}