From d52a9d77ab85cac9be2e562726b408bd43d19be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20L=C3=BCcke?= Date: Mon, 16 Jun 2025 15:14:31 +0200 Subject: [PATCH] Korrigiere PHP-Hinweise --- api/src/Models/WorkingHoursView.php | 23 ++++++------------- .../WorkingHoursMonthlyViewRepository.php | 4 ++-- .../Repositories/WorkingHoursRepository.php | 13 +++++++---- .../WorkingHoursWeeklyViewRepository.php | 4 ++-- .../WorkingHoursYearlyViewRepository.php | 4 ++-- api/tests/api.suite.dist.yml | 2 +- .../Controller/WorkingHoursControllerTest.php | 6 ----- 7 files changed, 23 insertions(+), 33 deletions(-) diff --git a/api/src/Models/WorkingHoursView.php b/api/src/Models/WorkingHoursView.php index bdeef5c..77bf15d 100644 --- a/api/src/Models/WorkingHoursView.php +++ b/api/src/Models/WorkingHoursView.php @@ -10,24 +10,14 @@ use JetBrains\PhpStorm\ArrayShape; class WorkingHoursView implements ModelInterface { - protected DateTimeInterface $period; - protected PeriodDesignationEnum $periodDesignation; - protected int $workingDays; - protected DateInterval $totalHours; - protected DateInterval $overtime; public function __construct( - DateTimeInterface $period, - PeriodDesignationEnum $periodDesignation, - int $workingDays, - DateInterval $totalHours, - DateInterval $overtime + protected DateTimeInterface $period, + protected PeriodDesignationEnum $periodDesignation, + protected int $workingDays, + protected DateInterval $totalHours, + protected DateInterval $overtime ) { - $this->period = $period; - $this->periodDesignation = $periodDesignation; - $this->workingDays = $workingDays; - $this->totalHours = $totalHours; - $this->overtime = $overtime; } public function getPeriod(): DateTimeInterface @@ -66,7 +56,8 @@ class WorkingHoursView implements ModelInterface 'totalHours' => "string", 'workingDays' => "int", 'overtime' => "string" - ])] public function jsonSerialize(): array + ])] + public function jsonSerialize(): array { $formatOvertime = (($this->getOvertime()->invert === 1) ? '-' : '') . '%H:%I:%S'; return [ diff --git a/api/src/Repositories/WorkingHoursMonthlyViewRepository.php b/api/src/Repositories/WorkingHoursMonthlyViewRepository.php index a307076..f20e1eb 100644 --- a/api/src/Repositories/WorkingHoursMonthlyViewRepository.php +++ b/api/src/Repositories/WorkingHoursMonthlyViewRepository.php @@ -12,7 +12,7 @@ use TorstenHettstedt\TimekeepingApi\Models\PeriodDesignationEnum; class WorkingHoursMonthlyViewRepository extends AbstractWorkingHoursViewRepository { - protected const SQL_SELECT = <<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(); diff --git a/api/src/Repositories/WorkingHoursWeeklyViewRepository.php b/api/src/Repositories/WorkingHoursWeeklyViewRepository.php index e0f383b..a0627fc 100644 --- a/api/src/Repositories/WorkingHoursWeeklyViewRepository.php +++ b/api/src/Repositories/WorkingHoursWeeklyViewRepository.php @@ -11,7 +11,7 @@ use TorstenHettstedt\TimekeepingApi\Models\PeriodDesignationEnum; class WorkingHoursWeeklyViewRepository extends AbstractWorkingHoursViewRepository { - protected const SQL_SELECT = <<