created = new \DateTime(); $this->visible = true; $this->publicKey = $this->generateToken(); } private function generateToken($length = 64){ $hash = ""; while(strlen($hash) < $length){ try { $hash .= hash('sha512', random_bytes($length)); } catch (\Exception $e) { $hash .= hash('sha512', mt_rand(0,$length*10000)); } } return substr($hash, 0,$length); } /** * @return int */ public function getId() { return $this->id; } /** * @param CustomCompanyInterface $company * @return $this */ public function setCompany(CustomCompanyInterface $company) { $this->company = $company; return $this; } /** * @return CustomCompanyInterface */ public function getCompany(): CustomCompanyInterface { return $this->company; } /** * @return \DateTime */ public function getCreated(): \DateTime { return $this->created; } /** * @param bool $visible * @return $this */ public function setVisible(bool $visible) { $this->visible = $visible; return $this; } /** * @return bool */ public function isVisible(): bool { return $this->visible; } /** * @param string $name * @return $this */ public function setName(string $name) { $this->name = $name; return $this; } /** * @return string */ public function getName(): string { return $this->name; } /** * @return string */ public function getPublicKey(): string { return $this->publicKey; } /** * @return string|null */ public function getEmail(): ?string { return $this->email; } /** * @param string $email * @return CompanyServiceBase */ public function setEmail(string $email): CompanyServiceBase { $this->email = $email; return $this; } }