@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function register() |
| 15 | 15 | { |
| 16 | - $this->app->singleton(Cloner::class, function () { |
|
| 16 | + $this->app->singleton(Cloner::class, function() { |
|
| 17 | 17 | return new Cloner(new CloneService, new PersistenceService); |
| 18 | 18 | }); |
| 19 | 19 | |
@@ -28,10 +28,10 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | private function persistRecursive($parent) |
| 30 | 30 | { |
| 31 | - NullWrapper::from($parent)->each(function ($model) { |
|
| 32 | - NullWrapper::from($model->getRelations())->filter(function ($relationModel) { |
|
| 31 | + NullWrapper::from($parent)->each(function($model) { |
|
| 32 | + NullWrapper::from($model->getRelations())->filter(function($relationModel) { |
|
| 33 | 33 | return ! is_a($relationModel, Pivot::class); |
| 34 | - })->each(function ($relationModel, $relationName) use ($model) { |
|
| 34 | + })->each(function($relationModel, $relationName) use ($model) { |
|
| 35 | 35 | $className = \get_class((new ReflectionObject($model))->newInstance()->{$relationName}()); |
| 36 | 36 | $strategy = $this->getPersistenceStrategy($className); |
| 37 | 37 | (new $strategy($model))->persist($relationName, $relationModel); |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | private function cloneRecursive($model) |
| 30 | 30 | { |
| 31 | - NullWrapper::from($model)->each(function ($item) { |
|
| 32 | - NullWrapper::from($item->getRelations())->each(function ($method, $relation) use ($item) { |
|
| 31 | + NullWrapper::from($model)->each(function($item) { |
|
| 32 | + NullWrapper::from($item->getRelations())->each(function($method, $relation) use ($item) { |
|
| 33 | 33 | $collection = $this->getFreshInstance($this->cloneRecursive($method), $item); |
| 34 | 34 | |
| 35 | 35 | $item->setRelation( |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | private function getFreshInstance($model, $parent) : Collection |
| 66 | 66 | { |
| 67 | - return NullWrapper::from($model)->map(function ($original) use ($parent) { |
|
| 68 | - return tap(new $original, function ($instance) use ($original, $parent) { |
|
| 67 | + return NullWrapper::from($model)->map(function($original) use ($parent) { |
|
| 68 | + return tap(new $original, function($instance) use ($original, $parent) { |
|
| 69 | 69 | $filter = [ |
| 70 | 70 | $original->getForeignKey(), |
| 71 | 71 | $original->getKeyName(), |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $original->getUpdatedAtColumn(), |
| 74 | 74 | ]; |
| 75 | 75 | |
| 76 | - if (! is_a($instance, Pivot::class)) { |
|
| 76 | + if ( ! is_a($instance, Pivot::class)) { |
|
| 77 | 77 | array_push($filter, $parent->getForeignKey()); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | public function persist(string $relationName, $models) : void |
| 25 | 25 | { |
| 26 | - NullWrapper::from($models)->each(function ($model) use ($relationName) { |
|
| 26 | + NullWrapper::from($models)->each(function($model) use ($relationName) { |
|
| 27 | 27 | $this->baseModel->{$relationName}()->attach([$this->baseModel->id => $model->pivot->getAttributes()]); |
| 28 | 28 | }); |
| 29 | 29 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | public function persist(string $relationName, $models) : void |
| 25 | 25 | { |
| 26 | - NullWrapper::from($models)->each(function ($model) use ($relationName) { |
|
| 26 | + NullWrapper::from($models)->each(function($model) use ($relationName) { |
|
| 27 | 27 | $this->baseModel->{$relationName}()->save($model); |
| 28 | 28 | }); |
| 29 | 29 | } |