The factory generator can be useful for setting up relationships between models. The factory generator will return the model id of the model you ask it to generate.
저자: Graham Campbell (graham@alt-three.com)
저자: Scott Robertson (scottymeuk@gmail.com)
저자: Michael Bodnarchuk (davert@codeception.com)
상속: extends EntityGenerator
예제 #1
0
 /**
  * Automatically make the generator class we need.
  *
  * @param string|callable                     $kind          The kind of attribute.
  * @param object                              $model         The model instance.
  * @param \League\FactoryMuffin\FactoryMuffin $factoryMuffin The factory muffin instance.
  *
  * @return \League\FactoryMuffin\Generators\GeneratorInterface|null
  */
 public function make($kind, $model, FactoryMuffin $factoryMuffin)
 {
     if (is_callable($kind)) {
         return new CallableGenerator($kind, $model, $factoryMuffin);
     }
     if (is_string($kind) && strpos($kind, EntityGenerator::getPrefix()) === 0) {
         return new EntityGenerator($kind, $model, $factoryMuffin);
     }
     if (is_string($kind) && strpos($kind, FactoryGenerator::getPrefix()) === 0) {
         return new FactoryGenerator($kind, $model, $factoryMuffin);
     }
 }