original_string: public function rootRelative($baseUrl)
      {
          $url = $this->url;
  
          $parsedBaseUrl = parse_url($baseUrl) + array(
                  'path' => '',
              );
          if (!isset($parsedBaseUrl['scheme'], $parsedBaseUrl['host'])) {
              throw new \Exception('Invalid base url "' . $baseUrl . '": scheme not found.');
          }
  
          if (empty($url)) {
              return $parsedBaseUrl['path'] . (isset($parsedBaseUrl['query']) ? '?' . $parsedBaseUrl['query'] : '');
          }
  
          $parsedUrl = parse_url($url) + array(
                  'path' => '/',
              );
          if (substr($url, 0, 1) == '?') {
              return $parsedBaseUrl['path'] . $url;
          }
  
          if (substr($url, 0, 3) == '../') {
              $pathParts = explode('/', $parsedBaseUrl['path']);
              array_pop($pathParts);
  
              while (substr($url, 0, 3) == '../') {
                  array_pop($pathParts);
                  $url = substr($url, 3);
              }
  
              return implode('/', $pathParts) . '/' . $url;
          }
  
          return $parsedUrl['path'] . (isset($parsedUrl['query']) ? '?' . $parsedUrl['query'] : '');
      }
code: public function rootRelative($baseUrl)
      {
          $url = $this->url;
  
          $parsedBaseUrl = parse_url($baseUrl) + array(
                  'path' => '',
              );
          if (!isset($parsedBaseUrl['scheme'], $parsedBaseUrl['host'])) {
              throw new \Exception('Invalid base url "' . $baseUrl . '": scheme not found.');
          }
  
          if (empty($url)) {
              return $parsedBaseUrl['path'] . (isset($parsedBaseUrl['query']) ? '?' . $parsedBaseUrl['query'] : '');
          }
  
          $parsedUrl = parse_url($url) + array(
                  'path' => '/',
              );
          if (substr($url, 0, 1) == '?') {
              return $parsedBaseUrl['path'] . $url;
          }
  
          if (substr($url, 0, 3) == '../') {
              $pathParts = explode('/', $parsedBaseUrl['path']);
              array_pop($pathParts);
  
              while (substr($url, 0, 3) == '../') {
                  array_pop($pathParts);
                  $url = substr($url, 3);
              }
  
              return implode('/', $pathParts) . '/' . $url;
          }
  
          return $parsedUrl['path'] . (isset($parsedUrl['query']) ? '?' . $parsedUrl['query'] : '');
      }
code_tokens: public function rootRelative ( $ baseUrl ) { $ url = $ this -> url ; $ parsedBaseUrl = parse_url ( $ baseUrl ) + array ( 'path' => '' , ) ; if ( ! isset ( $ parsedBaseUrl [ 'scheme' ] , $ parsedBaseUrl [ 'host' ] ) ) { throw new \ Exception ( 'Invalid base url "' . $ baseUrl . '": scheme not found.' ) ; } if ( empty ( $ url ) ) { return $ parsedBaseUrl [ 'path' ] . ( isset ( $ parsedBaseUrl [ 'query' ] ) ? '?' . $ parsedBaseUrl [ 'query' ] : '' ) ; } $ parsedUrl = parse_url ( $ url ) + array ( 'path' => '/' , ) ; if ( substr ( $ url , 0 , 1 ) == '?' ) { return $ parsedBaseUrl [ 'path' ] . $ url ; } if ( substr ( $ url , 0 , 3 ) == '../' ) { $ pathParts = explode ( '/' , $ parsedBaseUrl [ 'path' ] ) ; array_pop ( $ pathParts ) ; while ( substr ( $ url , 0 , 3 ) == '../' ) { array_pop ( $ pathParts ) ; $ url = substr ( $ url , 3 ) ; } return implode ( '/' , $ pathParts ) . '/' . $ url ; } return $ parsedUrl [ 'path' ] . ( isset ( $ parsedUrl [ 'query' ] ) ? '?' . $ parsedUrl [ 'query' ] : '' ) ; }
docstring: Returns root relative url.
  @param string $baseUrl base url to create absolute url.
  @return string
  @throws \Exception if baseUrl is invalid
docstring_tokens: Returns root relative url .