posts = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getEmail(): ?string { return $this->email; } public function setEmail(string $email): self { $this->email = $email; return $this; } /** * A visual identifier that represents this user. * * @see UserInterface */ public function getUsername(): string { return (string) $this->email; } /** * @see UserInterface */ public function getRoles(): array { $roles = $this->roles; // guarantee every user at least has ROLE_USER $roles[] = 'ROLE_USER'; if ($this->getIsAdmin()) { $roles[] = 'ROLE_ADMIN'; } return array_unique($roles); } public function setRoles(array $roles): self { $this->roles = $roles; return $this; } /** * @see UserInterface */ public function getPassword(): string { return (string) $this->password; } public function setPassword(string $password): self { $this->password = $password; return $this; } /** * Returning a salt is only needed, if you are not using a modern * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml. * * @see UserInterface */ public function getSalt(): ?string { return null; } /** * @see UserInterface */ public function eraseCredentials() { // If you store any temporary, sensitive data on the user, clear it here // $this->plainPassword = null; } public function getDisplayName(): ?string { return $this->displayName; } public function setDisplayName(?string $displayName): self { $this->displayName = $displayName; return $this; } public function getTotpSecret(): ?string { return $this->totpSecret; } public function setTotpSecret(?string $totpSecret): self { $this->totpSecret = $totpSecret; return $this; } public function isTotpAuthenticationEnabled(): bool { return null !== $this->getTotpSecret(); } public function getTotpAuthenticationUsername(): string { return $this->getEmail(); } public function getTotpAuthenticationConfiguration(): TotpConfigurationInterface { return new TotpConfiguration($this->totpSecret, TotpConfiguration::ALGORITHM_SHA1, 30, 6); } public function isGoogleAuthenticatorEnabled(): bool { return $this->isTotpAuthenticationEnabled(); } public function getGoogleAuthenticatorUsername(): string { return $this->getTotpAuthenticationUsername(); } public function getGoogleAuthenticatorSecret(): ?string { return $this->getTotpSecret(); } public function setGoogleAuthenticatorSecret(?string $googleAuthenticatorSecret): void { $this->setTotpSecret($googleAuthenticatorSecret); } public function getPasswordRequestedAt(): ?\DateTimeInterface { return $this->passwordRequestedAt; } public function setPasswordRequestedAt(?\DateTimeInterface $passwordRequestedAt): self { $this->passwordRequestedAt = $passwordRequestedAt; return $this; } public function getConfirmationToken(): ?string { return $this->confirmationToken; } public function setConfirmationToken(?string $confirmationToken): self { $this->confirmationToken = $confirmationToken; return $this; } public function getIsAdmin(): ?bool { return $this->isAdmin; } public function setIsAdmin(bool $isAdmin): self { $this->isAdmin = $isAdmin; return $this; } /** * @return Collection|Post[] */ public function getPosts(): Collection { return $this->posts; } public function addPost(Post $post): self { if (!$this->posts->contains($post)) { $this->posts[] = $post; $post->setAuthor($this); } return $this; } public function removePost(Post $post): self { if ($this->posts->removeElement($post)) { // set the owning side to null (unless already changed) if ($post->getAuthor() === $this) { $post->setAuthor(null); } } return $this; } }