employee = $employee; $this->start = new \DateTime('now'); } /** * Get id. * * @return int Model id * * @since 1.0.0 */ public function getId() : int { return $this->id; } /** * Get the employee this history belongs to * * @return int|Employee * * @since 1.0.0 */ public function getEmployee() { return empty($this->employee) ? new NullEmployee() : $this->employee; } /** * Get start date * * @return \DateTime * * @since 1.0.0 */ public function getStart() : \DateTime { return $this->start; } /** * Set start date * * @param \DateTime $start Start date * * @return void * * @since 1.0.0 */ public function setStart(\DateTime $start) : void { $this->start = $start; } /** * Get end date * * @return null|\DateTime * * @since 1.0.0 */ public function getEnd() : ?\DateTime { return $this->end; } /** * Set end date * * @param \DateTime $end End date * * @return void * * @since 1.0.0 */ 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, 'start' => $this->start, 'end' => $this->end, ]; } /** * {@inheritdoc} */ public function __toString() { return (string) \json_encode($this->toArray()); } /** * {@inheritdoc} */ public function jsonSerialize() { return $this->toArray(); } }