Skip to content

Commit

Permalink
Make Faker seed configurable (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored May 6, 2017
1 parent d6c6275 commit ada6119
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit ada6119

Please sign in to comment.