mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-01 04:23:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -11,11 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Search;
|
||||
|
||||
use function array_push;
|
||||
use function count;
|
||||
use function implode;
|
||||
use function strtr;
|
||||
|
||||
/**
|
||||
* This create a query optimized for searching for the api response.
|
||||
*
|
||||
@@ -24,9 +19,9 @@ use function strtr;
|
||||
*
|
||||
* `SELECT '<key>' as key, <metadata> as metadata, <pertinence> as pertinence FROM <from clause> WHERE <where clause>`.
|
||||
*
|
||||
* The clause between `<>` are provided through the dedicated method in this class (@link{self::setSelectKey},
|
||||
* @link{self::setFromClause}), etc.).
|
||||
* The clause between `<>` are provided through the dedicated method in this class (@see{self::setSelectKey},
|
||||
*
|
||||
* @see{self::setFromClause}), etc.).
|
||||
*/
|
||||
class SearchApiQuery
|
||||
{
|
||||
@@ -76,7 +71,7 @@ class SearchApiQuery
|
||||
public function andWhereClause(string $whereClause, array $params = []): self
|
||||
{
|
||||
$this->whereClauses[] = $whereClause;
|
||||
array_push($this->whereClausesParams, ...$params);
|
||||
\array_push($this->whereClausesParams, ...$params);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -99,18 +94,18 @@ class SearchApiQuery
|
||||
|
||||
public function buildQuery(bool $countOnly = false): string
|
||||
{
|
||||
$isMultiple = count($this->whereClauses);
|
||||
$isMultiple = \count($this->whereClauses);
|
||||
$where =
|
||||
($isMultiple ? '(' : '') .
|
||||
implode(
|
||||
($isMultiple ? ')' : '') . ' AND ' . ($isMultiple ? '(' : ''),
|
||||
($isMultiple ? '(' : '').
|
||||
\implode(
|
||||
($isMultiple ? ')' : '').' AND '.($isMultiple ? '(' : ''),
|
||||
$this->whereClauses
|
||||
) .
|
||||
).
|
||||
($isMultiple ? ')' : '');
|
||||
|
||||
$select = $this->buildSelectClause($countOnly);
|
||||
|
||||
return strtr('SELECT
|
||||
return \strtr('SELECT
|
||||
{select}
|
||||
FROM {from}
|
||||
WHERE {where}
|
||||
@@ -218,24 +213,24 @@ class SearchApiQuery
|
||||
return 'count(*) AS c';
|
||||
}
|
||||
|
||||
return 'count(distinct ' . $this->isDistinctKey . ') AS c';
|
||||
return 'count(distinct '.$this->isDistinctKey.') AS c';
|
||||
}
|
||||
|
||||
$selects = $this->getSelectClauses();
|
||||
|
||||
if (null !== $this->selectKey) {
|
||||
$selects[] = strtr("'{key}' AS key", ['{key}' => $this->selectKey]);
|
||||
$selects[] = \strtr("'{key}' AS key", ['{key}' => $this->selectKey]);
|
||||
}
|
||||
|
||||
if (null !== $this->jsonbMetadata) {
|
||||
$selects[] = strtr('{metadata} AS metadata', ['{metadata}' => $this->jsonbMetadata]);
|
||||
$selects[] = \strtr('{metadata} AS metadata', ['{metadata}' => $this->jsonbMetadata]);
|
||||
}
|
||||
|
||||
if (null !== $this->pertinence) {
|
||||
$selects[] = strtr('{pertinence} AS pertinence', ['{pertinence}' => $this->pertinence]);
|
||||
$selects[] = \strtr('{pertinence} AS pertinence', ['{pertinence}' => $this->pertinence]);
|
||||
}
|
||||
|
||||
return ($this->isDistinct ? 'DISTINCT ' : '') . implode(', ', $selects);
|
||||
return ($this->isDistinct ? 'DISTINCT ' : '').\implode(', ', $selects);
|
||||
}
|
||||
|
||||
private function buildSelectParams(bool $count = false): array
|
||||
|
Reference in New Issue
Block a user