original_string: public function getUrlForPath($path)
      {
          $fragments = parse_url($path);
  
          if (!isset($fragments['path']))
              throw new UrlException("URL is not a valid path: '$path'");
  
          $newUrl = clone $this;
          $newUrl->_fragments['path'] = $fragments['path'];
  
          // overwrite RHS components
          foreach (array('query', 'fragment') as $component) {
              if (isset($fragments[$component]))
                  $newUrl->_fragments[$component] = $fragments[$component];
              elseif (isset($newUrl->_fragments[$component]))
                  unset($newUrl->_fragments[$component]);
          }
  
          // store the new URL internally
          $newUrl->_inputString = $newUrl->__toString();
  
          return $newUrl;
      }
code: public function getUrlForPath($path)
      {
          $fragments = parse_url($path);
  
          if (!isset($fragments['path']))
              throw new UrlException("URL is not a valid path: '$path'");
  
          $newUrl = clone $this;
          $newUrl->_fragments['path'] = $fragments['path'];
  
          // overwrite RHS components
          foreach (array('query', 'fragment') as $component) {
              if (isset($fragments[$component]))
                  $newUrl->_fragments[$component] = $fragments[$component];
              elseif (isset($newUrl->_fragments[$component]))
                  unset($newUrl->_fragments[$component]);
          }
  
          // store the new URL internally
          $newUrl->_inputString = $newUrl->__toString();
  
          return $newUrl;
      }
code_tokens: public function getUrlForPath ( $ path ) { $ fragments = parse_url ( $ path ) ; if ( ! isset ( $ fragments [ 'path' ] ) ) throw new UrlException ( "URL is not a valid path: '$path'" ) ; $ newUrl = clone $ this ; $ newUrl -> _fragments [ 'path' ] = $ fragments [ 'path' ] ; // overwrite RHS components foreach ( array ( 'query' , 'fragment' ) as $ component ) { if ( isset ( $ fragments [ $ component ] ) ) $ newUrl -> _fragments [ $ component ] = $ fragments [ $ component ] ; elseif ( isset ( $ newUrl -> _fragments [ $ component ] ) ) unset ( $ newUrl -> _fragments [ $ component ] ) ; } // store the new URL internally $ newUrl -> _inputString = $ newUrl -> __toString ( ) ; return $ newUrl ; }
docstring: Builds a URL with a different path component
  @return Url
docstring_tokens: Builds a URL with a different path component