period = $period; $this->periodDesignation = $periodDesignation; $this->workingDays = $workingDays; $this->totalHours = $totalHours; $this->overtime = $overtime; } /** * @return DateTimeInterface */ public function getPeriod(): DateTimeInterface { return $this->period; } /** * @return PeriodDesignationEnum */ public function getPeriodDesignation(): PeriodDesignationEnum { return $this->periodDesignation; } /** * @return int */ public function getWorkingDays(): int { return $this->workingDays; } /** * @return DateInterval */ public function getTotalHours(): DateInterval { return $this->totalHours; } /** * @return DateInterval */ public function getOvertime(): DateInterval { return $this->overtime; } /** * @inheritDoc * * @return array */ #[ArrayShape(['period' => "string", 'periodDesignation' => "string", 'totalHours' => "string", 'workingDays' => "int", 'overtime' => "string" ])] public function jsonSerialize(): array { $formatOvertime = (($this->getOvertime()->invert === 1) ? '-' : '') . '%H:%I:%S'; return [ 'period' => $this->getPeriod()->format($this->getPeriodDesignation()->getValue()), 'periodDesignation' => strtolower($this->getPeriodDesignation()->getKey()), 'workingDays' => $this->getWorkingDays(), 'totalHours' => $this->getTotalHours()->format('%H:%I:%S'), 'overtime' => $this->getOvertime()->format($formatOvertime) ]; } }