created = new \DateTime(); $this->regeneratePublicKey(); $this->publicVisible = true; $this->deleted = 0; } 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); } /** * use to change the pk if its not unique */ public function regeneratePublicKey(){ $this->publicKey = $this->generateToken(); } /** * Get id * * @return int */ public function getId(): ?int { return $this->id; } /** * Set name * * @param string $name * * @return $this */ public function setName($name) { $this->name = $name; return $this; } /** * Get name * * @return string */ public function getName() { return $this->name; } /** * Set pro * * @param boolean $pro * * @return $this */ public function setPro($pro) { $this->pro = $pro; return $this; } /** * Get pro * * @return bool */ public function getPro() { return $this->pro; } /** * @return \DateTime */ public function getCreated(): \DateTime { return $this->created; } /** * @return string */ public function getPublicKey(): string { return $this->publicKey; } /** * @param bool $publicVisible * @return $this */ public function setPublicVisible(bool $publicVisible) { $this->publicVisible = $publicVisible; return $this; } /** * @return bool */ public function isPublicVisible(): bool { return $this->publicVisible; } /** * @return int|null */ public function getReferenceExterne(): ?int { return $this->referenceExterne; } /** * @param int $referenceExterne * @return CompanyBase */ public function setReferenceExterne(int $referenceExterne): CompanyBase { $this->referenceExterne = $referenceExterne; return $this; } /** * @return bool */ public function isDeleted(): bool { return $this->deleted; } /** * @param bool $deleted * @return CompanyBase */ public function setDeleted(bool $deleted): CompanyBase { $this->deleted = $deleted; return $this; } }