pathMatches = $pathMatches; return $target; } public function withHostMatches(array $hostMatches): self { $target = clone $this; $target->hostMatches = $hostMatches; return $target; } public function getRoute(): SymfonyRoute { return $this->route; } public function getRouteResult(): array { return $this->routeResult; } public function getFallbackScore(): int { return $this->route->getOption('fallback') === true ? 1 : 0; } public function getHostMatchScore(): int { return empty($this->hostMatches[0]) ? 0 : 1; } public function getPathMatchScore(int $index): int { $completeMatch = $this->pathMatches[0]; $tailMatch = $this->pathMatches[$index] ?? ''; // no tail, it's a complete match if ($tailMatch === '') { return strlen($completeMatch); } // otherwise, find length of complete match that does not contain tail // example: complete: `/french/other`, tail: `/other` -> `strlen` of `/french` return strrpos($completeMatch, $tailMatch); } public function getSiteIdentifier(): string { $site = $this->route->getDefault('site'); return $site instanceof SiteInterface ? $site->getIdentifier() : ''; } }