code: protected function checkAndSetAuthentication($repositoryName, $username, $password = null)
      {
          if ($this->hasAuthentication($repositoryName)) {
              $auth = $this->getAuthentication($repositoryName);
              if ($auth['username'] === $username && $auth['password'] === $password) {
                  return;
              }
  
              $this->writeError(
                  sprintf(
                      "<warning>Warning: You should avoid overwriting already defined auth settings for %s.</warning>",
                      $repositoryName
                  )
              );
          }
          $this->setAuthentication($repositoryName, $username, $password);
      }
docs: Check for overwrite and set the authentication information for the repository.
  
  @param string $repositoryName The unique name of repository
  @param string $username       The username
  @param string $password       The password