profile = $profile ?? new NullProfile(); $this->semiPrivateHash = \random_bytes(self::SEMI_PRIVATE_HASH_LENGTH); $this->image = new NullMedia(); } /** * Get id. * * @return int Employee id * * @since 1.0.0 */ public function getId() : int { return $this->id; } /** * Update semi private hash. * * @return void * * @since 1.0.0 */ public function updateSemiPrivateHash() : void { $this->semiPrivateHash = \random_bytes(self::SEMI_PRIVATE_HASH_LENGTH); } /** * Get semi private hash. * * @return string * * @since 1.0.0 */ public function getSemiPrivateHash() : string { return $this->semiPrivateHash; } /** * Compare two hashs * * @return bool * * @since 1.0.0 */ public function compareSemiPrivateHash(string $hash) : bool { return \hash_equals($this->semiPrivateHash, $hash); } /** * Get employee company history. * * @return array Employee history * * @since 1.0.0 */ public function getHistory() : array { return $this->companyHistory; } /** * Add company history to employee * * @param mixed $history Company history * * @return void * * @since 1.0.0 */ public function addHistory($history) : void { $this->companyHistory[] = $history; } /** * Get newest company history. * * @return EmployeeHistory * * @since 1.0.0 */ public function getNewestHistory() : EmployeeHistory { return empty($this->companyHistory) ? new NullEmployeeHistory() : \end($this->companyHistory); } /** * Get employee company education history. * * @return array Employee education history * * @since 1.0.0 */ public function getEducationHistory() : array { return $this->educationHistory; } /** * Get newest company education history. * * @return EmployeeEducationHistory * * @since 1.0.0 */ public function getNewestEducationHistory() : EmployeeEducationHistory { return empty($this->educationHistory) ? new NullEmployeeEducationHistory() : \end($this->educationHistory); } /** * Get employee company work. * * @return array Employee work * * @since 1.0.0 */ public function getWorkHistory() : array { return $this->workHistory; } /** * Get newest company work. * * @return EmployeeWorkHistory * * @since 1.0.0 */ public function getNewestWorkHistory() : EmployeeWorkHistory { return empty($this->workHistory) ? new NullEmployeeWorkHistory() : \end($this->workHistory); } /** * {@inheritdoc} */ public function toArray() : array { return [ 'id' => $this->id, 'profile' => $this->profile, ]; } /** * {@inheritdoc} */ public function __toString() { return (string) \json_encode($this->toArray()); } /** * {@inheritdoc} */ public function jsonSerialize() { return $this->toArray(); } }