The factory implements the singleton pattern as it is not meant to be used with a Dependency Injection container as new instances are created with a locale value which is determined at runtime.
コード例 #1
0
 private function getGenerator(GeneratorFactory $factory, string $formatter)
 {
     $explodedFormatter = explode(':', $formatter);
     $size = count($explodedFormatter);
     if (1 === $size) {
         return [$factory->getSeedGenerator(), $explodedFormatter[0]];
     }
     if (2 === $size) {
         return [$factory->createOrReturnExistingInstance($explodedFormatter[0]), $explodedFormatter[1]];
     }
     throw InvalidArgumentExceptionFactory::createForInvalidFakerFormatter($formatter);
 }
コード例 #2
0
ファイル: GeneratorFactoryTest.php プロジェクト: nelmio/alice
 public function testCanReturnDecoratedGenerator()
 {
     $generator = FakerFactory::create();
     $factory = new GeneratorFactory($generator);
     $this->assertSame($generator, $factory->getSeedGenerator());
 }