public function getNewUsernameFromUserDetails($email, $suggestedUsername = '', $firstName = '', $lastName = '')
    {
        $baseUsername = $this->stringToUsernameChunk($suggestedUsername);
        if ($baseUsername === '') {
            $firstName = $this->stringToUsernameChunk($firstName);
            $lastName = $this->stringToUsernameChunk($lastName);
            if ($firstName !== '' || $lastName !== '') {
                $baseUsername = trim($firstName . '_' . $lastName, '_');
            } else {
                $mailbox = strstr((string) $email, '@', true);
                $baseUsername = $this->stringToUsernameChunk($mailbox);
            }
            if ($baseUsername === '') {
                $baseUsername = 'user';
            }
        }
        $username = $baseUsername;
        $suffix = 1;
        while ($this->userInfoRepository->getByName($username) !== null) {
            $username = $baseUsername . '_' . $suffix;
            ++$suffix;
        }

        return $username;
    }