From 4fbb9bd63908f774254a8a17e7a146d4d049e933 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 7 Mar 2024 13:01:23 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/Api/Controllers/DeletePollOptionImageController.php | 1 - src/Api/Controllers/UploadPollImageController.php | 2 +- src/Api/Controllers/UploadPollOptionImageController.php | 5 +++-- src/Api/Serializers/PollOptionSerializer.php | 1 - src/Commands/CreatePollHandler.php | 2 +- src/Commands/EditPollHandler.php | 6 +++--- src/Validators/PollOptionValidator.php | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Api/Controllers/DeletePollOptionImageController.php b/src/Api/Controllers/DeletePollOptionImageController.php index 29678cd4..63aaee43 100644 --- a/src/Api/Controllers/DeletePollOptionImageController.php +++ b/src/Api/Controllers/DeletePollOptionImageController.php @@ -12,7 +12,6 @@ namespace FoF\Polls\Api\Controllers; use Flarum\Http\RequestUtil; -use FoF\Polls\Poll; use FoF\Polls\PollOption; use Illuminate\Contracts\Filesystem\Cloud; use Illuminate\Contracts\Filesystem\Factory; diff --git a/src/Api/Controllers/UploadPollImageController.php b/src/Api/Controllers/UploadPollImageController.php index 39fe1bf8..12a6e79d 100644 --- a/src/Api/Controllers/UploadPollImageController.php +++ b/src/Api/Controllers/UploadPollImageController.php @@ -79,7 +79,7 @@ protected function createLocalPath(string $filename, ?string $pollId): string return $filename; } - protected function linkToRecord(int $pollId, string $uploadName):void + protected function linkToRecord(int $pollId, string $uploadName): void { if ($pollId && $poll = Poll::find($pollId)) { $poll->image = $uploadName; diff --git a/src/Api/Controllers/UploadPollOptionImageController.php b/src/Api/Controllers/UploadPollOptionImageController.php index bed394e3..e35fea15 100644 --- a/src/Api/Controllers/UploadPollOptionImageController.php +++ b/src/Api/Controllers/UploadPollOptionImageController.php @@ -22,13 +22,14 @@ class UploadPollOptionImageController extends UploadPollImageController protected function createLocalPath(string $filename, ?string $pollId): string { - if(!$pollId) { + if (!$pollId) { throw new \InvalidArgumentException('Poll ID is required'); } + return "pollOptions/{$pollId}/{$filename}"; } - protected function linkToRecord(int $pollId, string $uploadName):void + protected function linkToRecord(int $pollId, string $uploadName): void { if ($pollId && $pollOption = PollOption::find($pollId)) { $pollOption->image = $uploadName; diff --git a/src/Api/Serializers/PollOptionSerializer.php b/src/Api/Serializers/PollOptionSerializer.php index d888f363..1a6be99d 100755 --- a/src/Api/Serializers/PollOptionSerializer.php +++ b/src/Api/Serializers/PollOptionSerializer.php @@ -12,7 +12,6 @@ namespace FoF\Polls\Api\Serializers; use Flarum\Api\Serializer\AbstractSerializer; -use FoF\Polls\Poll; use FoF\Polls\PollOption; use Illuminate\Contracts\Filesystem\Cloud; use Illuminate\Contracts\Filesystem\Factory; diff --git a/src/Commands/CreatePollHandler.php b/src/Commands/CreatePollHandler.php index 65552d6d..d114f7a6 100644 --- a/src/Commands/CreatePollHandler.php +++ b/src/Commands/CreatePollHandler.php @@ -84,7 +84,7 @@ public function handle(CreatePoll $command) foreach ($rawOptionsData as $rawOptionData) { $optionsData[] = [ 'answer' => Arr::get($rawOptionData, 'answer'), - 'image' => Arr::get($rawOptionData, 'image'), + 'image' => Arr::get($rawOptionData, 'image'), 'imageAlt' => Arr::get($rawOptionData, 'imageAlt'), ]; } diff --git a/src/Commands/EditPollHandler.php b/src/Commands/EditPollHandler.php index a43c16e5..90e8ec45 100755 --- a/src/Commands/EditPollHandler.php +++ b/src/Commands/EditPollHandler.php @@ -126,8 +126,8 @@ public function handle(EditPoll $command) $optionAttributes = [ 'answer' => Arr::get($opt, 'attributes.answer'), - 'image' => Arr::get($opt, 'attributes.image') ?: null, - 'imageAlt' => Arr::get($opt, 'attributes.imageAlt') ?: null + 'image' => Arr::get($opt, 'attributes.image') ?: null, + 'imageAlt' => Arr::get($opt, 'attributes.imageAlt') ?: null, ]; if (!$this->settings->get('fof-polls.allowOptionImage')) { @@ -141,7 +141,7 @@ public function handle(EditPoll $command) 'id' => $id, ], [ 'answer' => Arr::get($optionAttributes, 'answer'), - 'image' => Arr::get($optionAttributes, 'image'), + 'image' => Arr::get($optionAttributes, 'image'), 'image_alt' => Arr::get($optionAttributes, 'imageAlt'), ]); } diff --git a/src/Validators/PollOptionValidator.php b/src/Validators/PollOptionValidator.php index 289026c5..e730b73f 100755 --- a/src/Validators/PollOptionValidator.php +++ b/src/Validators/PollOptionValidator.php @@ -19,7 +19,7 @@ protected function getRules() { return [ 'answer' => ['required', 'string', 'max:255'], - 'image' => ['nullable', 'string', 'max:255'], + 'image' => ['nullable', 'string', 'max:255'], 'imageAlt' => ['nullable', 'string', 'max:255'], ]; }