本文整理匯總了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.');
}