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
+7 -16
View File
@@ -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 [
@@ -12,7 +12,7 @@ use TorstenHettstedt\TimekeepingApi\Models\PeriodDesignationEnum;
class WorkingHoursMonthlyViewRepository extends AbstractWorkingHoursViewRepository
{
protected const SQL_SELECT = <<<SQL
protected const string SQL_SELECT = <<<SQL
select
"Monat" as "period",
"Gesamtarbeitszeit" as "totalHours",
@@ -20,7 +20,7 @@ class WorkingHoursMonthlyViewRepository extends AbstractWorkingHoursViewReposito
"Überstunden" as "overtime"
from "Arbeitszeiten - Monat"
SQL;
protected const SQL_WHERE = ' where "Monat" = ?';
protected const string SQL_WHERE = ' where "Monat" = ?';
public function __construct(PDO $database)
{
@@ -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();
@@ -11,7 +11,7 @@ use TorstenHettstedt\TimekeepingApi\Models\PeriodDesignationEnum;
class WorkingHoursWeeklyViewRepository extends AbstractWorkingHoursViewRepository
{
protected const SQL_SELECT = <<<SQL
protected const string SQL_SELECT = <<<SQL
select
"Woche" as "period",
"Gesamtarbeitszeit" as "totalHours",
@@ -19,7 +19,7 @@ class WorkingHoursWeeklyViewRepository extends AbstractWorkingHoursViewRepositor
"Überstunden" as "overtime"
from "Arbeitszeiten - Woche"
SQL;
protected const SQL_WHERE = ' where "Woche" = ?';
protected const string SQL_WHERE = ' where "Woche" = ?';
public function __construct(PDO $database)
{
@@ -11,7 +11,7 @@ use TorstenHettstedt\TimekeepingApi\Models\PeriodDesignationEnum;
class WorkingHoursYearlyViewRepository extends AbstractWorkingHoursViewRepository
{
protected const SQL_SELECT = <<<SQL
protected const string SQL_SELECT = <<<SQL
select
"Jahr" as "period",
"Gesamtarbeitszeit" as "totalHours",
@@ -19,7 +19,7 @@ class WorkingHoursYearlyViewRepository extends AbstractWorkingHoursViewRepositor
"Überstunden" as "overtime"
from "Arbeitszeiten - Jahr"
SQL;
protected const SQL_WHERE = ' where "Jahr" = ?';
protected const string SQL_WHERE = ' where "Jahr" = ?';
public function __construct(PDO $database)
{