Determines the fitness of the provided path.
string $path: The path whose fitness we want.
int The fitness of the path, as an integer.
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;
}