start = new \DateTime('now'); } /** * Get id. * * @return int Account id * * @since 1.0.0 */ public function getId() : int { return $this->id; } /** * Add a session element to the session * * @param int|SessionElement $element Session element * * @return void * * @since 1.0.0 */ public function addSessionElement($element) : void { $this->sessionElement[] = $element; // todo: if quit element or pause element re-calculate busy time! } /** * Get busy time * * @return int * * @since 1.0.0 */ public function getBusy() : int { return $this->busy; } /** * Get the session type * * @return int * * @since 1.0.0 */ public function getType() : int { return $this->type; } /** * Set the session type * * @param int $type Session type * * @return void * * @since 1.0.0 */ public function setType(int $type) : void { $this->type = $type; } /** * Return session start * * @return \DateTime * * @since 1.0.0 */ public function getStart() : \DateTime { return $this->start; } /** * Return session end * * @return null|\DateTime * * @since 1.0.0 */ public function getEnd() : ?\DateTime { return $this->end; } /** * {@inheritdoc} */ public function toArray() : array { return [ 'id' => $this->id, 'start' => $this->start->format('Y-m-d H:i:s'), 'end' => $this->end === null ? null : $this->end->format('Y-m-d H:i:s'), 'busy' => $this->busy, 'type' => $this->type, 'employee' => $this->employee, 'elements' => $this->sessionElements, ]; } /** * {@inheritdoc} */ public function __toString() { return (string) \json_encode($this->toArray()); } /** * {@inheritdoc} */ public function jsonSerialize() { return $this->toArray(); } }