From 2972876c37bbe865188ac560beae4ab6c2cd7003 Mon Sep 17 00:00:00 2001 From: Lupacescu Eduard Date: Wed, 20 May 2020 10:58:41 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/Fields/Field.php | 12 ++++++------ tests/Controllers/RepositoryShowControllerTest.php | 4 ++-- tests/Unit/FieldTest.php | 3 +-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Fields/Field.php b/src/Fields/Field.php index c201872c3..dcc5ad0e9 100644 --- a/src/Fields/Field.php +++ b/src/Fields/Field.php @@ -198,12 +198,12 @@ public function fillAttribute(RestifyRequest $request, $model) $this->resolveValueBeforeUpdate($request, $model); if ($this->isHidden($request)) { - if (!isset($this->appendCallback)) { + if (! isset($this->appendCallback)) { return; } } - if (!$this->isHidden($request) && isset($this->fillCallback)) { + if (! $this->isHidden($request) && isset($this->fillCallback)) { return call_user_func( $this->fillCallback, $request, $model, $this->attribute ); @@ -253,7 +253,7 @@ protected function fillAttributeFromRequest(RestifyRequest $request, $model, $at */ protected function fillAttributeFromAppend(RestifyRequest $request, $model, $attribute) { - if (!isset($this->appendCallback)) { + if (! isset($this->appendCallback)) { return; } @@ -356,7 +356,7 @@ public function resolveForShow($repository, $attribute = null) return; } - if (!$this->showCallback) { + if (! $this->showCallback) { $this->resolve($repository, $attribute); } elseif (is_callable($this->showCallback)) { tap($this->value ?? $this->resolveAttribute($repository, $attribute), function ($value) use ($repository, $attribute) { @@ -379,7 +379,7 @@ public function resolveForIndex($repository, $attribute = null) return; } - if (!$this->indexCallback) { + if (! $this->indexCallback) { $this->resolve($repository, $attribute); } elseif (is_callable($this->indexCallback)) { tap($this->value ?? $this->resolveAttribute($repository, $attribute), function ($value) use ($repository, $attribute) { @@ -399,7 +399,7 @@ public function resolve($repository, $attribute = null) return; } - if (!$this->resolveCallback) { + if (! $this->resolveCallback) { $this->value = $this->resolveAttribute($repository, $attribute); } elseif (is_callable($this->resolveCallback)) { tap($this->resolveAttribute($repository, $attribute), function ($value) use ($repository, $attribute) { diff --git a/tests/Controllers/RepositoryShowControllerTest.php b/tests/Controllers/RepositoryShowControllerTest.php index 103287fb9..2d63b1a85 100644 --- a/tests/Controllers/RepositoryShowControllerTest.php +++ b/tests/Controllers/RepositoryShowControllerTest.php @@ -121,11 +121,11 @@ public function test_repository_hidden_fields_could_not_be_updated() public function test_repository_hidden_fields_could_be_updated_through_append() { - $post = factory(Post::class)->create(['user_id' => 2, 'title' => 'Eduard', 'category' => 'Hidden category before update.',]); + $post = factory(Post::class)->create(['user_id' => 2, 'title' => 'Eduard', 'category' => 'Hidden category before update.']); $this->putJson('/restify-api/post-with-hidden-fields/1', [ 'title' => 'Updated title', - 'category' => 'Trying to update hidden category.' + 'category' => 'Trying to update hidden category.', ]); $this->assertEquals('Append category for a hidden field.', $post->fresh()->category); diff --git a/tests/Unit/FieldTest.php b/tests/Unit/FieldTest.php index ec7a0ae9c..f38703018 100644 --- a/tests/Unit/FieldTest.php +++ b/tests/Unit/FieldTest.php @@ -3,7 +3,6 @@ namespace Binaryk\LaravelRestify\Tests\Unit; use Binaryk\LaravelRestify\Fields\Field; -use Binaryk\LaravelRestify\Http\Requests\RepositoryIndexRequest; use Binaryk\LaravelRestify\Http\Requests\RepositoryStoreRequest; use Binaryk\LaravelRestify\Http\Requests\RepositoryUpdateRequest; use Binaryk\LaravelRestify\Tests\Fixtures\Post\PostRepository; @@ -292,7 +291,7 @@ public function test_field_can_be_filled_from_the_append_callback() }; /** * @var Field $field */ - $field = Field::new('title')->append(fn() => 'Append title'); + $field = Field::new('title')->append(fn () => 'Append title'); $field->fillAttribute($request, $model);