From dd2731da98b0da51d6c5f7d38ac1a6b0eb6891a2 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 2 Mar 2020 22:49:01 +0100 Subject: [PATCH] php cs and stan fixes --- Models/Employee.php | 2 + Models/EmployeeEducationHistory.php | 185 ++++++++++++++++++++++++ Models/EmployeeWorkHistory.php | 185 ++++++++++++++++++++++++ Models/NullEmployeeEducationHistory.php | 27 ++++ Models/NullEmployeeWorkHistory.php | 27 ++++ 5 files changed, 426 insertions(+) create mode 100644 Models/EmployeeEducationHistory.php create mode 100644 Models/EmployeeWorkHistory.php create mode 100644 Models/NullEmployeeEducationHistory.php create mode 100644 Models/NullEmployeeWorkHistory.php diff --git a/Models/Employee.php b/Models/Employee.php index 7acdd22..a77d7ab 100644 --- a/Models/Employee.php +++ b/Models/Employee.php @@ -14,8 +14,10 @@ declare(strict_types=1); namespace Modules\HumanResourceManagement\Models; +use Modules\Media\Models\Media; use Modules\Media\Models\NullMedia; use Modules\Profile\Models\Profile; + use phpOMS\Contract\ArrayableInterface; /** diff --git a/Models/EmployeeEducationHistory.php b/Models/EmployeeEducationHistory.php new file mode 100644 index 0000000..af0b717 --- /dev/null +++ b/Models/EmployeeEducationHistory.php @@ -0,0 +1,185 @@ +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(); + } +} diff --git a/Models/EmployeeWorkHistory.php b/Models/EmployeeWorkHistory.php new file mode 100644 index 0000000..ff5fcbd --- /dev/null +++ b/Models/EmployeeWorkHistory.php @@ -0,0 +1,185 @@ +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(); + } +} diff --git a/Models/NullEmployeeEducationHistory.php b/Models/NullEmployeeEducationHistory.php new file mode 100644 index 0000000..b2ce565 --- /dev/null +++ b/Models/NullEmployeeEducationHistory.php @@ -0,0 +1,27 @@ +