publicKey = $this->generateToken(64); $this->deleted = 0; $this->paymentsModes = new ArrayCollection(); } /** * @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); } public function getId(): ?int { return $this->id; } public function getPublicKey(): ?string { return $this->publicKey; } public function getGroupName(): ?string { return $this->groupName; } public function setGroupName(string $groupName): self { $this->groupName = $groupName; return $this; } public function getDeleted(): ?bool { return $this->deleted; } public function setDeleted(bool $deleted): self { $this->deleted = $deleted; return $this; } public function setPublicKey(string $publicKey): self { $this->publicKey = $publicKey; return $this; } /** * @return Collection|PaymentMode[] */ public function getPaymentsModes(): Collection { return $this->paymentsModes; } public function addPaymentsMode(PaymentMode $paymentsMode): self { if (!$this->paymentsModes->contains($paymentsMode)) { $this->paymentsModes[] = $paymentsMode; $paymentsMode->addGroup($this); } return $this; } public function removePaymentsMode(PaymentMode $paymentsMode): self { if ($this->paymentsModes->contains($paymentsMode)) { $this->paymentsModes->removeElement($paymentsMode); $paymentsMode->removeGroup($this); } return $this; } }