public function RouteCompiler::getFit

Determines the fitness of the provided path.

Parameters

string $path: The path whose fitness we want.

Return value

int The fitness of the path, as an integer.

1 call to RouteCompiler::getFit()
RouteCompiler::compile in drupal/core/lib/Drupal/Core/Routing/RouteCompiler.php
Compiles the current route instance.

File

drupal/core/lib/Drupal/Core/Routing/RouteCompiler.php, line 202
Definition of Drupal\Core\Routing\RouteCompiler.

Class

RouteCompiler
Compiler to generate derived information from a Route necessary for matching.

Namespace

Drupal\Core\Routing

Code

public function getFit($path) {
  $parts = explode('/', trim($path, '/'), static::MAX_PARTS);
  $number_parts = count($parts);

  // We store the highest index of parts here to save some work in the fit
  // calculation loop.
  $slashes = $number_parts - 1;
  $fit = 0;
  foreach ($parts as $k => $part) {
    if (strpos($part, '{') === FALSE) {
      $fit |= 1 << $slashes - $k;
    }
  }
  return $fit;
}