Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Faker seed configurable #726

Merged
merged 1 commit into from
May 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Loader/NativeLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
* Loader implementation made to be usable without any dependency injection for quick and easy usage. For more advanced
* usages, use {@see \Nelmio\Alice\Loader\SimpleFileLoader} instead or implement your own loader.
*
* WARNING: because this class is wrapping the whole configuration, the BC break policy is not fully ensured here. Not
* methods can be added in minor versions, which could make your application break if you are extending this class and
* have a method with the same name.
*
* @method DataLoaderInterface getDataLoader()
* @method FileLoaderInterface getFileLoader()
*
Expand Down Expand Up @@ -513,6 +517,7 @@ protected function createFakerGenerator(): FakerGenerator
{
$generator = FakerGeneratorFactory::create();
$generator->addProvider(new AliceProvider());
$generator->seed($this->getSeed());

return $generator;
}
Expand Down Expand Up @@ -559,6 +564,17 @@ protected function createCaller(): CallerInterface
return new SimpleCaller($this->getValueResolver());
}

/**
* Seed used to generate random data. The seed is passed to the random number generator, so calling the a script
* twice with the same seed produces the same results.
*
* @return int|null
*/
protected function getSeed()
{
return null;
}

public function __call(string $method, array $arguments)
{
if (array_key_exists($method, $this->cache)) {
Expand Down