username = $username; $this->password = $encoder->encodePassword($rawPassword, null); $this->email = $email; $this->roles = $roles ?: ['ROLE_USER']; $this->createdAt = new \DateTime(); } public function getId(): int { return $this->id; } public function getUsername() { return $this->username; } public function getPassword() { return $this->password; } public function changePassword(PasswordEncoderInterface $encoder, string $rawPassword): void { $this->password = $encoder->encodePassword($rawPassword, null); } public function getSalt() { // Salt is not needed when using Argon2i // @see https://symfony.com/doc/current/reference/configuration/security.html#using-the-argon2i-password-encoder return null; } public function getEmail(): string { return $this->email; } public function getRoles(): array { return $this->roles; } public function addRole(string $role): void { $this->roles[] = $role; } public function getCreatedAt(): \DateTime { return $this->createdAt; } public function eraseCredentials() { } /** @return Invite[]|ArrayCollection */ public function getInvites(): \Traversable { return $this->invites; } /** @see \Serializable::serialize() */ public function serialize() { return serialize([ $this->id, $this->username, $this->password, ]); } /** @see \Serializable::unserialize() */ public function unserialize($serialized) { [ $this->id, $this->username, $this->password ] = unserialize($serialized, ['allowed_classes' => false]); } }