Erweitere die Klassen
This commit is contained in:
@@ -10,8 +10,9 @@ use JetBrains\PhpStorm\ArrayShape;
|
||||
|
||||
class WorkingHours implements ModelInterface
|
||||
{
|
||||
protected ?DateTime $workingDay = null;
|
||||
protected ?DateTime $workingDay = null;
|
||||
protected ?DateInterval $workingTime = null;
|
||||
protected bool $isHomeOffice = false;
|
||||
|
||||
public function getWorkingDay(): ?DateTime
|
||||
{
|
||||
@@ -35,15 +36,27 @@ class WorkingHours implements ModelInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isHomeOffice(): bool
|
||||
{
|
||||
return $this->isHomeOffice;
|
||||
}
|
||||
|
||||
public function setIsHomeOffice(bool $isHomeOffice): WorkingHours
|
||||
{
|
||||
$this->isHomeOffice = $isHomeOffice;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
#[ArrayShape(['workingDay' => "string", 'workingTime' => "string"])]
|
||||
#[ArrayShape(['workingDay' => "string", 'workingTime' => "string", 'isHomeOffice' => "boolean"])]
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'workingDay' => $this->getWorkingDay()->format('Y-m-d'),
|
||||
'workingTime' => $this->getWorkingTime()->format('%H:%I:%S')
|
||||
'workingDay' => $this->getWorkingDay()->format('Y-m-d'),
|
||||
'workingTime' => $this->getWorkingTime()->format('%H:%I:%S'),
|
||||
'isHomeOffice' => $this->isHomeOffice(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ class WorkingHoursView implements ModelInterface
|
||||
protected PeriodDesignationEnum $periodDesignation,
|
||||
protected int $workingDays,
|
||||
protected DateInterval $totalHours,
|
||||
private int $homeOfficeDays,
|
||||
protected DateInterval $overtime
|
||||
) {
|
||||
}
|
||||
@@ -35,6 +36,11 @@ class WorkingHoursView implements ModelInterface
|
||||
return $this->workingDays;
|
||||
}
|
||||
|
||||
public function getHomeOfficeDays(): int
|
||||
{
|
||||
return $this->homeOfficeDays;
|
||||
}
|
||||
|
||||
public function getTotalHours(): DateInterval
|
||||
{
|
||||
return $this->totalHours;
|
||||
@@ -45,19 +51,13 @@ class WorkingHoursView implements ModelInterface
|
||||
return $this->overtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
#[ArrayShape([
|
||||
'period' => "string",
|
||||
'periodDesignation' => "string",
|
||||
'totalHours' => "string",
|
||||
'workingDays' => "int",
|
||||
'overtime' => "string"
|
||||
])]
|
||||
public function jsonSerialize(): array
|
||||
#[ArrayShape(['period' => "string",
|
||||
'periodDesignation' => "string",
|
||||
'totalHours' => "string",
|
||||
'workingDays' => "int",
|
||||
'homeOfficeDays' => "int",
|
||||
'overtime' => "string"
|
||||
])] public function jsonSerialize(): array
|
||||
{
|
||||
$formatOvertime = (($this->getOvertime()->invert === 1) ? '-' : '') . '%H:%I:%S';
|
||||
return [
|
||||
@@ -65,6 +65,7 @@ class WorkingHoursView implements ModelInterface
|
||||
'periodDesignation' => strtolower($this->getPeriodDesignation()->name),
|
||||
'workingDays' => $this->getWorkingDays(),
|
||||
'totalHours' => $this->getTotalHours()->format('%H:%I:%S'),
|
||||
'homeOfficeDays' => $this->getHomeOfficeDays(),
|
||||
'overtime' => $this->getOvertime()->format($formatOvertime)
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user