62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
<?php
|
|
|
|
|
|
namespace TorstenHettstedt\TimekeepingApi\Models;
|
|
|
|
|
|
use DateInterval;
|
|
use DateTime;
|
|
use JetBrains\PhpStorm\ArrayShape;
|
|
|
|
class WorkingHours implements ModelInterface
|
|
{
|
|
protected ?DateTime $workingDay = null;
|
|
protected ?DateInterval $workingTime = null;
|
|
protected bool $isHomeOffice = false;
|
|
|
|
public function getWorkingDay(): ?DateTime
|
|
{
|
|
return $this->workingDay;
|
|
}
|
|
|
|
public function setWorkingDay(DateTime $workingDay): static
|
|
{
|
|
$this->workingDay = $workingDay;
|
|
return $this;
|
|
}
|
|
|
|
public function getWorkingTime(): ?DateInterval
|
|
{
|
|
return $this->workingTime;
|
|
}
|
|
|
|
public function setWorkingTime(DateInterval $workingTime): static
|
|
{
|
|
$this->workingTime = $workingTime;
|
|
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", 'isHomeOffice' => "boolean"])]
|
|
public function jsonSerialize(): array
|
|
{
|
|
return [
|
|
'workingDay' => $this->getWorkingDay()->format('Y-m-d'),
|
|
'workingTime' => $this->getWorkingTime()->format('%H:%I:%S'),
|
|
'isHomeOffice' => $this->isHomeOffice(),
|
|
];
|
|
}
|
|
} |