start = new \DateTime('now'); } /** * Get id. * * @return int Model id * * @since 1.0.0 */ public function getId() : int { return $this->id; } public function getEmployee() { return $this->employee ?? new NullEmployee(); } public function setEmployee($employee) : void { $this->employee = $employee; } public function getPosition() : Position { return $this->position ?? new NullPosition(); } public function setPosition($position) : void { $this->position = $position; } public function getUnit() : Unit { return $this->unit ?? new NullUnit(); } public function setUnit($unit) : void { $this->unit = $unit; } public function getDepartment() : Department { return $this->department ?? new NullDepartment(); } public function setDepartment($department) : void { $this->department = $department; } public function getStart() : ?\DateTime { return $this->start; } public function setStart(\DateTime $start) : void { $this->start = $start; } public function getEnd() : ?\DateTime { return $this->end; } public function setEnd(\DateTime $end) : void { $this->end = $end; } /** * {@inheritdoc} */ public function toArray() : array { return [ 'id' => $this->id, 'employee' => !\is_int($this->employee) ? $this->employee->getId() : $this->employee, 'unit' => $this->unit, 'department' => $this->department, 'position' => $this->position, 'start' => $this->start->format('Y-m-d H:i:s'), 'end' => $this->end === null ? null : $this->end->format('Y-m-d H:i:s'), ]; } /** * {@inheritdoc} */ public function __toString() { return (string) \json_encode($this->toArray()); } /** * {@inheritdoc} */ public function jsonSerialize() { return $this->toArray(); } }