@@ -7,30 +7,30 @@ |
||
| 7 | 7 | |
| 8 | 8 | class FactoryMuffin extends OriginalFactoryMuffin |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Generate and set the model attributes. |
|
| 12 | - * NOTE: Patch the original method to support dynamic setter and getter |
|
| 13 | - * of the OCP\AppFramework\Db\Entity class |
|
| 14 | - * |
|
| 15 | - * @param object $model The model instance. |
|
| 16 | - * @param array $attr The model attributes. |
|
| 17 | - * |
|
| 18 | - * @return void |
|
| 19 | - */ |
|
| 20 | - protected function generate($model, array $attr = []) |
|
| 21 | - { |
|
| 22 | - foreach ($attr as $key => $kind) { |
|
| 23 | - $value = $this->factory->generate($kind, $model, $this); |
|
| 10 | + /** |
|
| 11 | + * Generate and set the model attributes. |
|
| 12 | + * NOTE: Patch the original method to support dynamic setter and getter |
|
| 13 | + * of the OCP\AppFramework\Db\Entity class |
|
| 14 | + * |
|
| 15 | + * @param object $model The model instance. |
|
| 16 | + * @param array $attr The model attributes. |
|
| 17 | + * |
|
| 18 | + * @return void |
|
| 19 | + */ |
|
| 20 | + protected function generate($model, array $attr = []) |
|
| 21 | + { |
|
| 22 | + foreach ($attr as $key => $kind) { |
|
| 23 | + $value = $this->factory->generate($kind, $model, $this); |
|
| 24 | 24 | |
| 25 | - $setter = 'set'.ucfirst(static::camelize($key)); |
|
| 26 | - // check if there is a setter and use it instead |
|
| 27 | - if ($model instanceof Entity && is_callable([$model, $setter])) { |
|
| 28 | - $model->$setter($value); |
|
| 29 | - } elseif (method_exists($model, $setter) && is_callable([$model, $setter])) { |
|
| 30 | - $model->$setter($value); |
|
| 31 | - } else { |
|
| 32 | - $model->$key = $value; |
|
| 33 | - } |
|
| 34 | - } |
|
| 35 | - } |
|
| 25 | + $setter = 'set'.ucfirst(static::camelize($key)); |
|
| 26 | + // check if there is a setter and use it instead |
|
| 27 | + if ($model instanceof Entity && is_callable([$model, $setter])) { |
|
| 28 | + $model->$setter($value); |
|
| 29 | + } elseif (method_exists($model, $setter) && is_callable([$model, $setter])) { |
|
| 30 | + $model->$setter($value); |
|
| 31 | + } else { |
|
| 32 | + $model->$key = $value; |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | } |