Skip to content

Commit

Permalink
Apply php-cs-fixer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattamon authored and github-actions[bot] committed May 23, 2024
1 parent 11e93a6 commit 7c4a173
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/Note/Service/FilterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace Pimcore\Bundle\StudioBackendBundle\Note\Service;

use Exception;
use Pimcore\Bundle\StaticResolverBundle\Db\DbResolverInterface;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidFilterException;
use Pimcore\Bundle\StudioBackendBundle\Note\Request\NoteElement;
use Pimcore\Bundle\StudioBackendBundle\Note\Request\NoteParameters;
Expand All @@ -41,7 +40,7 @@ public function applyFilter(NoteListing $list, NoteParameters $parameters): void
public function applyFieldFilters(NoteListing $list, NoteParameters $parameters): void
{
try {
if(!$parameters->getFieldFilters() || empty($parameters->getFieldFilters())) {
if (!$parameters->getFieldFilters() || empty($parameters->getFieldFilters())) {

Check failure on line 43 in src/Note/Service/FilterService.php

View workflow job for this annotation

GitHub Actions / static-analysis / Static Analysis with PHPStan (8.2, highest, false)

Expression in empty() is not falsy.

Check failure on line 43 in src/Note/Service/FilterService.php

View workflow job for this annotation

GitHub Actions / static-analysis / Static Analysis with PHPStan (8.2, highest, 11.x-dev as 11.99.9, true)

Expression in empty() is not falsy.
return;
}

Expand Down Expand Up @@ -90,17 +89,16 @@ public function applyElementFilter(NoteListing $list, NoteElement $noteElement):

private function prepareValue(string $type, string $operator, string $value): mixed
{
return match($type) {
return match ($type) {
'date' => strtotime($value),
default => $this->matchValueOperator($operator, $value)
};
}


private function matchValueOperator(string $operator, mixed $value): mixed
{
return match($operator) {
'boolean' => (int)$value,
return match ($operator) {
'boolean' => (int)$value,
default => $value
};
}
Expand All @@ -116,10 +114,9 @@ private function createFilterCondition(string $filter): string
. ')';
}


private function findOperator(string $type, string $operator): string
{
return match($type) {
return match ($type) {
'string' => 'LIKE',
'numeric', 'date' => $this->matchNumericOperator($operator),
default => '='
Expand All @@ -128,7 +125,7 @@ private function findOperator(string $type, string $operator): string

private function matchNumericOperator(string $operator): string
{
return match($operator) {
return match ($operator) {
'lt' => '<',
'lte' => '<=',
'gt' => '>',
Expand Down

0 comments on commit 7c4a173

Please sign in to comment.