original_string: public function changeUsername(User $user, string $newUsername): AuthenticationRecordInterface
      {
          /** @var AuthenticationRecordInterface $auth */
          $auth = $this->authenticationProvider->findByUserId($user->getId());
  
          if (!$auth) {
              throw new NoSuchUserException();
          }
  
          // check to see if already taken
          if ($otherAuth = $this->authenticationProvider->findByUsername($newUsername)) {
              if ($auth == $otherAuth) {
                  return $auth;
              } else {
                  throw new UsernameTakenException();
              }
          }
  
          $auth->setUsername($newUsername);
          $this->authenticationProvider->update($auth);
  
          return $auth;
      }
code: public function changeUsername(User $user, string $newUsername): AuthenticationRecordInterface
      {
          /** @var AuthenticationRecordInterface $auth */
          $auth = $this->authenticationProvider->findByUserId($user->getId());
  
          if (!$auth) {
              throw new NoSuchUserException();
          }
  
          // check to see if already taken
          if ($otherAuth = $this->authenticationProvider->findByUsername($newUsername)) {
              if ($auth == $otherAuth) {
                  return $auth;
              } else {
                  throw new UsernameTakenException();
              }
          }
  
          $auth->setUsername($newUsername);
          $this->authenticationProvider->update($auth);
  
          return $auth;
      }
code_tokens: public function changeUsername ( User $ user , string $ newUsername ) : AuthenticationRecordInterface { /** @var AuthenticationRecordInterface $auth */ $ auth = $ this -> authenticationProvider -> findByUserId ( $ user -> getId ( ) ) ; if ( ! $ auth ) { throw new NoSuchUserException ( ) ; } // check to see if already taken if ( $ otherAuth = $ this -> authenticationProvider -> findByUsername ( $ newUsername ) ) { if ( $ auth == $ otherAuth ) { return $ auth ; } else { throw new UsernameTakenException ( ) ; } } $ auth -> setUsername ( $ newUsername ) ; $ this -> authenticationProvider -> update ( $ auth ) ; return $ auth ; }
docstring: Change an auth record username given a user id and a new username.
  Note - in this case username is email.
  
  @param User $user
  @param      $newUsername
  
  @return AuthenticationRecordInterface
  @throws NoSuchUserException Thrown when the user's authentication records couldn't be found
  @throws UsernameTakenException
docstring_tokens: Change an auth record username given a user id and a new username . Note - in this case username is email .