mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-06 06:44:59 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,30 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Timeline;
|
||||
|
||||
use function strtr;
|
||||
|
||||
class TimelineSingleQuery
|
||||
{
|
||||
private ?string $id;
|
||||
|
||||
private ?string $date;
|
||||
|
||||
private ?string $key;
|
||||
|
||||
private ?string $from;
|
||||
|
||||
private ?string $where;
|
||||
|
||||
private array $parameters = [];
|
||||
|
||||
private bool $distinct = false;
|
||||
|
||||
private ?string $from;
|
||||
|
||||
private ?string $id;
|
||||
|
||||
private ?string $key;
|
||||
|
||||
private array $parameters = [];
|
||||
|
||||
private ?string $where;
|
||||
|
||||
public function __construct(
|
||||
string $id = null,
|
||||
string $date = null,
|
||||
string $key = null,
|
||||
string $from = null,
|
||||
string $where = null,
|
||||
?string $id = null,
|
||||
?string $date = null,
|
||||
?string $key = null,
|
||||
?string $from = null,
|
||||
?string $where = null,
|
||||
array $parameters = []
|
||||
) {
|
||||
$this->id = $id;
|
||||
@@ -35,6 +43,27 @@ class TimelineSingleQuery
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
public function buildSql(): string
|
||||
{
|
||||
$parameters = [];
|
||||
|
||||
return strtr(
|
||||
'SELECT {distinct} {id} AS id, '
|
||||
. '{date} AS "date", '
|
||||
. "'{key}' AS type "
|
||||
. 'FROM {from} '
|
||||
. 'WHERE {where}',
|
||||
[
|
||||
'{distinct}' => $this->distinct ? 'DISTINCT' : '',
|
||||
'{id}' => $this->getId(),
|
||||
'{date}' => $this->getDate(),
|
||||
'{key}' => $this->getKey(),
|
||||
'{from}' => $this->getFrom(),
|
||||
'{where}' => $this->getWhere(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public static function fromArray(array $a)
|
||||
{
|
||||
return new TimelineSingleQuery(
|
||||
@@ -43,78 +72,49 @@ class TimelineSingleQuery
|
||||
$a['type'] ?? $a['key'] ?? null,
|
||||
$a['FROM'] ?? $a['from'] ?? null,
|
||||
$a['WHERE'] ?? $a['where'] ?? null,
|
||||
$a['parameters'] ?? null);
|
||||
}
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(string $id): self
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
$a['parameters'] ?? null
|
||||
);
|
||||
}
|
||||
|
||||
public function getDate(): string
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function setDate(string $date): self
|
||||
|
||||
public function getFrom(): string
|
||||
{
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
return $this->from;
|
||||
}
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getKey(): string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function setKey(string $key): self
|
||||
{
|
||||
$this->key = $key;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFrom(): string
|
||||
public function getParameters(): array
|
||||
{
|
||||
return $this->from;
|
||||
}
|
||||
|
||||
public function setFrom(string $from): self
|
||||
{
|
||||
$this->from = $from;
|
||||
|
||||
return $this;
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
public function getWhere(): string
|
||||
{
|
||||
return $this->where;
|
||||
}
|
||||
|
||||
public function setWhere(string $where): self
|
||||
|
||||
public function isDistinct(): bool
|
||||
{
|
||||
$this->where = $where;
|
||||
|
||||
return $this;
|
||||
return $this->distinct;
|
||||
}
|
||||
|
||||
public function getParameters(): array
|
||||
public function setDate(string $date): self
|
||||
{
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
public function setParameters(array $parameters): self
|
||||
{
|
||||
$this->parameters = $parameters;
|
||||
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -125,31 +125,38 @@ class TimelineSingleQuery
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isDistinct(): bool
|
||||
public function setFrom(string $from): self
|
||||
{
|
||||
return $this->distinct;
|
||||
$this->from = $from;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function buildSql(): string
|
||||
public function setId(string $id): self
|
||||
{
|
||||
$parameters = [];
|
||||
$this->id = $id;
|
||||
|
||||
$sql = \strtr(
|
||||
'SELECT {distinct} {id} AS id, '
|
||||
. '{date} AS "date", '
|
||||
. "'{key}' AS type "
|
||||
. 'FROM {from} '
|
||||
. 'WHERE {where}',
|
||||
[
|
||||
'{distinct}' => $this->distinct ? 'DISTINCT' : '',
|
||||
'{id}' => $this->getId(),
|
||||
'{date}' => $this->getDate(),
|
||||
'{key}' => $this->getKey(),
|
||||
'{from}' => $this->getFrom(),
|
||||
'{where}' => $this->getWhere(),
|
||||
]
|
||||
);
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $sql;
|
||||
public function setKey(string $key): self
|
||||
{
|
||||
$this->key = $key;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setParameters(array $parameters): self
|
||||
{
|
||||
$this->parameters = $parameters;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setWhere(string $where): self
|
||||
{
|
||||
$this->where = $where;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user