employee = $employee; $this->start = new \DateTime('now'); $this->address = new Address(); } /** * Get id. * * @return int Model id * * @since 1.0.0 */ public function getId() : int { return $this->id; } /** * Get files * * @return Media[] * * @since 1.0.0 */ public function getFiles() : array { return $this->files; } /** * Get media file by type * * @param null|int $type Media type * * @return Media * * @since 1.0.0 */ public function getFileByType(int $type = null) : Media { foreach ($this->files as $file) { if ($file->type === $type) { return $file; } } return new NullMedia(); } /** * Get all media files by type * * @param null|int $type Media type * * @return Media[] * * @since 1.0.0 */ public function getFilesByType(int $type = null) : array { $files = []; foreach ($this->files as $file) { if ($file->type === $type) { $files[] = $file; } } return $files; } /** * {@inheritdoc} */ public function toArray() : array { return [ 'id' => $this->id, 'employee' => !\is_int($this->employee) ? $this->employee->getId() : $this->employee, 'jobTitle' => $this->jobTitle, 'start' => $this->start, 'end' => $this->end, ]; } /** * {@inheritdoc} */ public function jsonSerialize() : mixed { return $this->toArray(); } }