code: private function getBaseUri($url)
      {
          if (null === $url) {
              throw new InvalidCredentialsException('invalid creddentials');
          }
  
          $parts = parse_url($url);
  
          if (empty($parts['scheme'])) {
              $parts['scheme'] = 'http';
          }
  
          return sprintf('%s://%s/%s/', $parts['scheme'], $parts['host'], 'rest');
      }
docs: @param string $url
  
  @return string