formForgeReasonResponse = $reasonResponse; $this->publicKey = $this->generateToken(64); $this->files = new ArrayCollection(); } 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(); } /** * @return int */ public function getId(): int { return $this->id; } /** * @param FormForgeReasonResponseInterface $formForgeReasonResponse * @return FormForgeFieldResponseBase */ public function setFormForgeReasonResponse(FormForgeReasonResponseInterface $formForgeReasonResponse ): FormForgeFieldResponseBase { $this->formForgeReasonResponse = $formForgeReasonResponse; return $this; } /** * @return FormForgeReasonResponseInterface */ public function getFormForgeReasonResponse(): FormForgeReasonResponseInterface { return $this->formForgeReasonResponse; } /** * @param FormForgeFieldInterface $formForgeField * @return FormForgeFieldResponseBase */ public function setFormForgeField(FormForgeFieldInterface $formForgeField): FormForgeFieldResponseBase { $this->formForgeField = $formForgeField; return $this; } /** * @return FormForgeFieldInterface */ public function getFormForgeField(): FormForgeFieldInterface { return $this->formForgeField; } /** * @param string $value * @return FormForgeFieldResponseBase */ public function setValue(string $value): FormForgeFieldResponseBase { $this->value = $value; return $this; } /** * @return string */ public function getValue(): string { return $this->value; } /** * @param int $order * @return FormForgeFieldResponseBase */ public function setOrder(int $order): FormForgeFieldResponseBase { $this->order = $order; return $this; } /** * @return int */ public function getOrder(): int { return $this->order; } /** * @return string */ public function getPublicKey(): string { return $this->publicKey; } /** * @param FileItem $file * @return Collection */ public function addFile(FileItem $file): Collection { if(!$this->files->contains($file)){ $this->files->add($file); } return $this->files; } /** * @param FileItem $file * @return Collection */ public function removeFile(FileItem $file): Collection { if($this->files->contains($file)){ $this->files->removeElement($file); } return $this->files; } /** * @return Collection */ public function getFiles(): Collection { return $this->files; } /** * @return string */ public function getAdditionalValue(): string { return $this->additionalValue; } /** * @param string $additionalValue * @return FormForgeFieldResponseBase */ public function setAdditionalValue(string $additionalValue): FormForgeFieldResponseBase { $this->additionalValue = $additionalValue; return $this; } }