publicKey = $this->generateToken(64); $this->ostDate = new \DateTime(); $this->deleted = false; $this->resolve = false; } /** * @param TicketItemInterface $ticketItem * @param string $content * @param CustomUserInterface $fromUser */ public function setDefault(TicketItemInterface $ticketItem, string $content, CustomUserInterface $fromUser){ $this->ticketItem = $ticketItem; $this->content = $content; $this->fromUser = $fromUser; } /** * @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); } /** * use to change the pk if its not unique */ public function regeneratePublicKey(){ $this->publicKey = $this->generateToken(); } /** * Get id * * @return int */ public function getId() { return $this->id; } /** * @param $content * @return $this */ public function setContent($content) { $this->content = $content; return $this; } /** * @return string */ public function getContent() { return $this->content; } /** * @param TicketItemInterface $ticket * @return TicketMessageBase */ public function setTicketItem(TicketItemInterface $ticket): TicketMessageBase { $this->ticketItem = $ticket; return $this; } /** * @return TicketItemInterface */ public function getTicketItem(): TicketItemInterface { return $this->ticketItem; } /** * @param CustomUserInterface $fromUser * @return TicketMessageBase */ public function setFromUser(CustomUserInterface $fromUser): TicketMessageBase { $this->fromUser = $fromUser; return $this; } /** * @return CustomUserInterface */ public function getFromUser(): CustomUserInterface { return $this->fromUser; } /** * @return string */ public function getPublicKey(): string { return $this->publicKey; } /** * @param \DateTime $ostDate * @return TicketMessageBase */ public function setOstDate(\DateTime $ostDate): TicketMessageBase { $this->ostDate = $ostDate; return $this; } /** * @return \DateTime */ public function getOstDate(): \DateTime { return $this->ostDate; } /** * @param bool $resolve * @return TicketMessageBase */ public function setResolve(bool $resolve): TicketMessageBase { $this->resolve = $resolve; return $this; } /** * @return bool */ public function isResolve(): bool { return $this->resolve; } /** * @param bool $deleted * @return TicketMessageBase */ public function setDeleted(bool $deleted): TicketMessageBase { $this->deleted = $deleted; return $this; } /** * @return bool */ public function isDeleted(): bool { return $this->deleted; } public function setPublicKey(string $publicKey): self { $this->publicKey = $publicKey; return $this; } }