getName() ?? $this->getEmail(); } /** * The email * * @return string|null The email */ public function getEmail (): ?string { return $this->email; } /** * Change the email * * @param string $email The new email * * @return $this */ public function setEmail (string $email): self { $this->email = $email; return $this; } /** * The hashed password * * @return string The hashed password * * @see PasswordAuthenticatedUserInterface */ public function getPassword (): string { return $this->password; } /** * Change the hashed password * * @param string $password The new hashed password * * @return $this */ public function setPassword (string $password): self { $this->password = $password; return $this; } /** * The name * * @return string|null The name */ public function getName (): ?string { return $this->name; } /** * Change the name * * @param string|null $name The new name * * @return $this */ public function setName (?string $name): self { $this->name = $name; return $this; } /** * A visual identifier that represents this user * * @see UserInterface */ public function getUserIdentifier (): string { return $this->email; } /** * Has a role ? * * @param string $role The role * * @return bool True if the user has the role, else False */ public function hasRole (string $role): bool { return in_array($role, $this->getRoles()); } /** * The roles * * @return string[] The roles * * @see UserInterface */ public function getRoles (): array { $roles = $this->roles; // guarantee every user at least has ROLE_USER $roles[] = 'ROLE_USER'; return array_unique($roles); } /** * Set the roles * * @param array $roles The new roles * * @return void */ public function setRoles (array $roles): void { $this->roles = $roles; } /** * Removes sensitive data from the user * * @see UserInterface */ public function eraseCredentials (): void { } }