Author: Graham Campbell (graham@alt-three.com)
Author: Scott Robertson (scottymeuk@gmail.com)
Author: Michael Bodnarchuk (davert@codeception.com)
 /**
  * Generate and set the model attributes.
  *
  * @param object $model The model instance.
  * @param array  $attr  The model attributes.
  *
  * @return void
  */
 protected function generate($model, array $attr = [])
 {
     foreach ($attr as $key => $kind) {
         $value = $this->generatorFactory->generate($kind, $model, $this);
         $setter = 'set' . ucfirst(self::camelize($key));
         // check if there is a setter and use it instead
         if (method_exists($model, $setter)) {
             $model->{$setter}($value);
         } else {
             $model->{$key} = $value;
         }
     }
 }
Beispiel #2
0
 /**
  * Generate and set the model attributes.
  *
  * @param object $model The model instance.
  * @param array  $attr  The model attributes.
  *
  * @return void
  */
 protected function generate($model, array $attr = [])
 {
     foreach ($attr as $key => $kind) {
         $model->{$key} = $this->generatorFactory->generate($kind, $model, $this);
     }
 }