entries = new ArrayCollection(); $this->roles = ['ROLE_USER']; } /** * Set name. * * @param string $name * * @return User */ public function setName($name) { $this->name = $name; return $this; } /** * Get name. * * @return string */ public function getName() { return $this->name; } /** * @return \DateTime */ public function getCreatedAt() { return $this->createdAt; } /** * @return \DateTime */ public function getUpdatedAt() { return $this->updatedAt; } /** * @param Entry $entry * * @return User */ public function addEntry(Entry $entry) { $this->entries[] = $entry; return $this; } /** * @return ArrayCollection */ public function getEntries() { return $this->entries; } public function isEqualTo(UserInterface $user) { return $this->username === $user->getUsername(); } /** * Set config. * * @param Config $config * * @return User */ public function setConfig(Config $config = null) { $this->config = $config; return $this; } /** * Get config. * * @return Config */ public function getConfig() { return $this->config; } /** * @return bool */ public function isEmailTwoFactor() { return $this->emailTwoFactor; } /** * @param bool $emailTwoFactor */ public function setEmailTwoFactor($emailTwoFactor) { $this->emailTwoFactor = $emailTwoFactor; } /** * Used in the user config form to be "like" the email option. */ public function isGoogleTwoFactor() { return $this->isGoogleAuthenticatorEnabled(); } /** * {@inheritdoc} */ public function isEmailAuthEnabled(): bool { return $this->emailTwoFactor; } /** * {@inheritdoc} */ public function getEmailAuthCode(): string { return $this->authCode; } /** * {@inheritdoc} */ public function setEmailAuthCode(string $authCode): void { $this->authCode = $authCode; } /** * {@inheritdoc} */ public function getEmailAuthRecipient(): string { return $this->email; } /** * {@inheritdoc} */ public function isGoogleAuthenticatorEnabled(): bool { return $this->googleAuthenticatorSecret ? true : false; } /** * {@inheritdoc} */ public function getGoogleAuthenticatorUsername(): string { return $this->username; } /** * {@inheritdoc} */ public function getGoogleAuthenticatorSecret(): string { return $this->googleAuthenticatorSecret; } /** * {@inheritdoc} */ public function setGoogleAuthenticatorSecret(?string $googleAuthenticatorSecret): void { $this->googleAuthenticatorSecret = $googleAuthenticatorSecret; } /** * @param Client $client * * @return User */ public function addClient(Client $client) { $this->clients[] = $client; return $this; } /** * @return ArrayCollection */ public function getClients() { return $this->clients; } /** * Only used by the API when creating a new user it'll also return the first client (which was also created at the same time). * * @return Client */ public function getFirstClient() { if (!empty($this->clients)) { return $this->clients->first(); } } }