protected function getUniqueUserName($name)
    {
        $i = 0;
        $testName = $name;

        do {
            $user = $this->userManager->findUserByUsername($testName);
        } while (null !== $user && $i < $this->iterations && $testName = $name.++$i);

        return null !== $user ? '' : $testName;
    }
protected function getUniqueUserName($name)
    {
        $i = 0;
        $testName = $name;

        do {
            $user = $this->userManager->findUserByUsername($testName);
        } while (null !== $user && $i < $this->iterations && $testName = $name.++$i);

        return null !== $user ? '' : $testName;
    }
protected function getUniqueUserName ( $ name ) { $ i = 0 ; $ testName = $ name ; do { $ user = $ this -> userManager -> findUserByUsername ( $ testName ) ; } while ( null !== $ user && $ i < $ this -> iterations && $ testName = $ name . ++ $ i ) ; return null !== $ user ? '' : $ testName ; }
Attempts to get a unique username for the user.

@param string $name

@return string name, or empty string if it failed after all the iterations
Attempts to get a unique username for the user .