From 6dfd3fca668309e10b9e46cba7624f26f0fd0f79 Mon Sep 17 00:00:00 2001 From: mattamon Date: Thu, 23 May 2024 09:58:25 +0200 Subject: [PATCH] Apply sonar cloud feedback --- src/Exception/InvalidFilterException.php | 6 +++--- src/Note/Service/FilterService.php | 4 ++-- .../Attributes/Parameters/Query/FieldFilterParameter.php | 5 ++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Exception/InvalidFilterException.php b/src/Exception/InvalidFilterException.php index f2d8d71d0..9a377b18b 100644 --- a/src/Exception/InvalidFilterException.php +++ b/src/Exception/InvalidFilterException.php @@ -23,9 +23,9 @@ final class InvalidFilterException extends AbstractApiException { public function __construct(string $filter) { - parent::__construct(400, sprintf( - 'Invalid filter: %s', - $filter) + parent::__construct( + 400, + sprintf('Invalid filter: %s', $filter) ); } } diff --git a/src/Note/Service/FilterService.php b/src/Note/Service/FilterService.php index 48b3c9b9f..837a797d9 100644 --- a/src/Note/Service/FilterService.php +++ b/src/Note/Service/FilterService.php @@ -31,7 +31,7 @@ public function applyFilter(NoteListing $list, NoteParameters $parameters): void { if ($parameters->getFilter()) { $list->addConditionParam( - $this->createFilterCondition($parameters->getFilter()), + $this->createFilterCondition(), ['filter' => '%' . $parameters->getFilter() . '%'] ); } @@ -103,7 +103,7 @@ private function matchValueOperator(string $operator, mixed $value): mixed }; } - private function createFilterCondition(string $filter): string + private function createFilterCondition(): string { return '(' . '`title` LIKE :filter' diff --git a/src/OpenApi/Attributes/Parameters/Query/FieldFilterParameter.php b/src/OpenApi/Attributes/Parameters/Query/FieldFilterParameter.php index 9505abdfc..e5b2eea14 100644 --- a/src/OpenApi/Attributes/Parameters/Query/FieldFilterParameter.php +++ b/src/OpenApi/Attributes/Parameters/Query/FieldFilterParameter.php @@ -29,7 +29,10 @@ public function __construct() description: 'Filter for specific fields, will be json decoded to an array.', in: 'query', required: false, - example: '[{"operator":"like","value":"John","field":"name","type":"string"}, {"operator":"eq","value":"10","property":"count","type":"numeric"} ]' + example: '[ + {"operator":"like","value":"John","field":"name","type":"string"}, + {"operator":"eq","value":"10","property":"count","type":"numeric"} + ]' ); } }