original_string: public static function route(Http\Request $request)
      {
          $path = $request->REQUEST_URI;
          $key = $request->getMethod().'@'.$path;
          $keyAny = 'ANY@'.$path;
  
          $matchedRoute = null;
          $matchedScore = 0;
  
          if (isset(self::$routes[$key])) {
              $matchedRoute = self::$routes[$key];
          } elseif (isset(self::$routes[$keyAny])) {
              $matchedRoute = self::$routes[$keyAny];
          } else {
              foreach (self::$routes as $key2 => $route) {
                  if ($route->getMethod() != 'ANY' && $route->getMethod() != $request->getMethod()) {
                      continue;
                  }
  
                  $score = $route->getScore($path, $request->getMethod());
                  if ($score > $matchedScore) {
                      $matchedRoute = $route;
                      $matchedScore = $score;
                  }
              }
          }
  
          if ($matchedRoute) {
              $matchedRoute->setUrl($path);
          } elseif (self::$_404route) {
              $matchedRoute = self::$_404route;
          } else {
              throw new Exceptions\RouteException('Route not found');
          }
          return $matchedRoute;
      }
code: public static function route(Http\Request $request)
      {
          $path = $request->REQUEST_URI;
          $key = $request->getMethod().'@'.$path;
          $keyAny = 'ANY@'.$path;
  
          $matchedRoute = null;
          $matchedScore = 0;
  
          if (isset(self::$routes[$key])) {
              $matchedRoute = self::$routes[$key];
          } elseif (isset(self::$routes[$keyAny])) {
              $matchedRoute = self::$routes[$keyAny];
          } else {
              foreach (self::$routes as $key2 => $route) {
                  if ($route->getMethod() != 'ANY' && $route->getMethod() != $request->getMethod()) {
                      continue;
                  }
  
                  $score = $route->getScore($path, $request->getMethod());
                  if ($score > $matchedScore) {
                      $matchedRoute = $route;
                      $matchedScore = $score;
                  }
              }
          }
  
          if ($matchedRoute) {
              $matchedRoute->setUrl($path);
          } elseif (self::$_404route) {
              $matchedRoute = self::$_404route;
          } else {
              throw new Exceptions\RouteException('Route not found');
          }
          return $matchedRoute;
      }
code_tokens: public static function route ( Http \ Request $ request ) { $ path = $ request -> REQUEST_URI ; $ key = $ request -> getMethod ( ) . '@' . $ path ; $ keyAny = 'ANY@' . $ path ; $ matchedRoute = null ; $ matchedScore = 0 ; if ( isset ( self :: $ routes [ $ key ] ) ) { $ matchedRoute = self :: $ routes [ $ key ] ; } elseif ( isset ( self :: $ routes [ $ keyAny ] ) ) { $ matchedRoute = self :: $ routes [ $ keyAny ] ; } else { foreach ( self :: $ routes as $ key2 => $ route ) { if ( $ route -> getMethod ( ) != 'ANY' && $ route -> getMethod ( ) != $ request -> getMethod ( ) ) { continue ; } $ score = $ route -> getScore ( $ path , $ request -> getMethod ( ) ) ; if ( $ score > $ matchedScore ) { $ matchedRoute = $ route ; $ matchedScore = $ score ; } } } if ( $ matchedRoute ) { $ matchedRoute -> setUrl ( $ path ) ; } elseif ( self :: $ _404route ) { $ matchedRoute = self :: $ _404route ; } else { throw new Exceptions \ RouteException ( 'Route not found' ) ; } return $ matchedRoute ; }
docstring: Initiate the routing for the given URL
docstring_tokens: Initiate the routing for the given URL