original_string: public function parse($url, $method = '')
      {
          $decoded = urldecode($url);
  
          // Sort path segments matching longest paths first.
          $paths = array_keys($this->_paths);
          rsort($paths);
  
          foreach ($paths as $path) {
              if (strpos($decoded, $path) !== 0) {
                  continue;
              }
  
              $queryParameters = null;
              if (strpos($url, '?') !== false) {
                  list($url, $queryParameters) = explode('?', $url, 2);
                  parse_str($queryParameters, $queryParameters);
              }
              /* @var \Cake\Routing\Route\Route $route */
              foreach ($this->_paths[$path] as $route) {
                  $r = $route->parse($url, $method);
                  if ($r === false) {
                      continue;
                  }
                  if ($queryParameters) {
                      $r['?'] = $queryParameters;
                  }
  
                  return $r;
              }
          }
  
          $exceptionProperties = ['url' => $url];
          if ($method !== '') {
              // Ensure that if the method is included, it is the first element of
              // the array, to match the order that the strings are printed in the
              // MissingRouteException error message, $_messageTemplateWithMethod.
              $exceptionProperties = array_merge(['method' => $method], $exceptionProperties);
          }
          throw new MissingRouteException($exceptionProperties);
      }
code: public function parse($url, $method = '')
      {
          $decoded = urldecode($url);
  
          // Sort path segments matching longest paths first.
          $paths = array_keys($this->_paths);
          rsort($paths);
  
          foreach ($paths as $path) {
              if (strpos($decoded, $path) !== 0) {
                  continue;
              }
  
              $queryParameters = null;
              if (strpos($url, '?') !== false) {
                  list($url, $queryParameters) = explode('?', $url, 2);
                  parse_str($queryParameters, $queryParameters);
              }
              /* @var \Cake\Routing\Route\Route $route */
              foreach ($this->_paths[$path] as $route) {
                  $r = $route->parse($url, $method);
                  if ($r === false) {
                      continue;
                  }
                  if ($queryParameters) {
                      $r['?'] = $queryParameters;
                  }
  
                  return $r;
              }
          }
  
          $exceptionProperties = ['url' => $url];
          if ($method !== '') {
              // Ensure that if the method is included, it is the first element of
              // the array, to match the order that the strings are printed in the
              // MissingRouteException error message, $_messageTemplateWithMethod.
              $exceptionProperties = array_merge(['method' => $method], $exceptionProperties);
          }
          throw new MissingRouteException($exceptionProperties);
      }
code_tokens: public function parse ( $ url , $ method = '' ) { $ decoded = urldecode ( $ url ) ; // Sort path segments matching longest paths first. $ paths = array_keys ( $ this -> _paths ) ; rsort ( $ paths ) ; foreach ( $ paths as $ path ) { if ( strpos ( $ decoded , $ path ) !== 0 ) { continue ; } $ queryParameters = null ; if ( strpos ( $ url , '?' ) !== false ) { list ( $ url , $ queryParameters ) = explode ( '?' , $ url , 2 ) ; parse_str ( $ queryParameters , $ queryParameters ) ; } /* @var \Cake\Routing\Route\Route $route */ foreach ( $ this -> _paths [ $ path ] as $ route ) { $ r = $ route -> parse ( $ url , $ method ) ; if ( $ r === false ) { continue ; } if ( $ queryParameters ) { $ r [ '?' ] = $ queryParameters ; } return $ r ; } } $ exceptionProperties = [ 'url' => $ url ] ; if ( $ method !== '' ) { // Ensure that if the method is included, it is the first element of // the array, to match the order that the strings are printed in the // MissingRouteException error message, $_messageTemplateWithMethod. $ exceptionProperties = array_merge ( [ 'method' => $ method ] , $ exceptionProperties ) ; } throw new MissingRouteException ( $ exceptionProperties ) ; }
docstring: Takes the URL string and iterates the routes until one is able to parse the route.
  
  @param string $url URL to parse.
  @param string $method The HTTP method to use.
  @return array An array of request parameters parsed from the URL.
  @throws \Cake\Routing\Exception\MissingRouteException When a URL has no matching route.
docstring_tokens: Takes the URL string and iterates the routes until one is able to parse the route .