moderated = false; $this->publicKey = $this->generateToken(); $this->delete = 0; } /** * @param int $length * @return bool|string */ 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|mixed */ public function getId() { return $this->id; } /** * @param FileItem|null $fori * @return Avatar */ public function setFori(?FileItem $fori): Avatar { $this->fori = $fori; return $this; } /** * @return FileItem|null */ public function getFori(): ?FileItem { return $this->fori; } /** * @param bool $moderated * @return Avatar */ public function setModerated(bool $moderated): Avatar { $this->moderated = $moderated; return $this; } /** * @return bool */ public function isModerated(): bool { return $this->moderated; } /** * @param UserFileOwnerInterface $userFileOwnerInterface * @return Avatar */ public function setUserFileOwnerInterface(UserFileOwnerInterface $userFileOwnerInterface): Avatar { $this->userFileOwnerInterface = $userFileOwnerInterface; return $this; } /** * @return UserFileOwnerInterface */ public function getUserFileOwnerInterface(): UserFileOwnerInterface { return $this->userFileOwnerInterface; } public function getModerated(): ?bool { return $this->moderated; } public function getFlarge(): ?string { return $this->flarge; } public function setFlarge(?string $flarge): self { $this->flarge = $flarge; return $this; } public function getFmedium(): ?string { return $this->fmedium; } public function setFmedium(?string $fmedium): self { $this->fmedium = $fmedium; return $this; } public function getFsmall(): ?string { return $this->fsmall; } public function setFsmall(?string $fsmall): self { $this->fsmall = $fsmall; return $this; } public function getPublicKey(): ?string { return $this->publicKey; } public function getDelete(): ?bool { return $this->delete; } public function setDelete(bool $delete): self { $this->delete = $delete; return $this; } public function setPublicKey(string $publicKey): self { $this->publicKey = $publicKey; return $this; } }