public static function authHttpsRemoteUrl()

in src/shipit/ShipItGitHubUtils.php [85:113]


  public static function authHttpsRemoteUrl(
    string $remote_url,
    ShipItTransport $transport,
    ShipItGitHubCredentials $credentials,
  ): string {
    if ($transport !== ShipItTransport::HTTPS) {
      return $remote_url;
    }
    $access_token = $credentials['access_token'];
    $auth_user = $access_token;
    if ($auth_user === null) {
      $user = $credentials['user'];
      $password = $credentials['password'];
      invariant(
        $user is nonnull && $password is nonnull,
        'Either an access token or user/password is required.',
      );
      $auth_user =
        Str\format('%s:%s', PHP\urlencode($user), PHP\urlencode($password));
    }
    if (Str\search($remote_url, self::GIT_HTTPS_URL_PREFIX) === 0) {
      $prefix_len = Str\length(self::GIT_HTTPS_URL_PREFIX);
      return Str\slice($remote_url, 0, $prefix_len).
        $auth_user.
        '@'.
        Str\slice($remote_url, $prefix_len);
    }
    return $remote_url;
  }