Korrigiere PHP-Hinweise

This commit is contained in:
2025-06-16 15:36:27 +02:00
parent a09edcae25
commit d52a9d77ab
7 changed files with 23 additions and 33 deletions
@@ -20,6 +20,13 @@ use TorstenHettstedt\TimekeepingApi\Models\WorkingHours;
*/
class WorkingHoursRepository implements RepositoryReaderInterface, RepositoryWriterInterface
{
protected const string SQL_SELECT = <<<'SQL'
select
"Datum" as "workingDay",
"Arbeitszeit" as "workingTime"
from public."Arbeitszeiten"
SQL;
public function __construct(protected PDO $database)
{
@@ -88,7 +95,7 @@ class WorkingHoursRepository implements RepositoryReaderInterface, RepositoryWri
protected function buildFindFilteredStatement(?string $start, ?string $end): ?PDOStatement
{
$query = 'select "Datum" as "workingDay", "Arbeitszeit" as "workingTime" from public."Arbeitszeiten" ';
$query = static::SQL_SELECT . ' ';
$query .= $this->buildFilterString($start, $end);
$query .= 'order by "Datum"';
$stmt = $this->database->prepare($query);
@@ -113,9 +120,7 @@ class WorkingHoursRepository implements RepositoryReaderInterface, RepositoryWri
*/
public function findByKey(mixed $primary_key): WorkingHours
{
$stmt = $this->database->prepare(
'select "Datum" as "workingDay", "Arbeitszeit" as "workingTime" from public."Arbeitszeiten" where "Datum" = ?'
);
$stmt = $this->database->prepare(static::SQL_SELECT . ' where "Datum" = ?');
$stmt->bindParam(1, $primary_key);
$stmt->execute();
$row = $stmt->fetch();