src/Viserio/Component/Routing/TreeGenerator/RouteTreeCompiler.php
private function compileRouteTree(PHPCodeCollection $code, array $routeTree): void
    {
        $code->appendLine('switch (count($segments)) {');

        $code->indent++;

        foreach ($routeTree[1] as $segmentDepth => $nodes) {
            $code->appendLine('case ' . $segmentDepth . ':');

            $code->indent++;

            $segmentVariables = [];

            for ($i = 0; $i < $segmentDepth; $i++) {
                $segmentVariables[$i] = '$s' . $i;
            }

            $code->appendLine('[' . \implode(', ', $segmentVariables) . '] = $segments;');

            $this->compileSegmentNodes($code, $nodes, $segmentVariables);
            $this->compileDisallowedHttpMethodOrNotFound($code);

            $code->appendLine('break;');

            $code->indent--;

            $code->appendLine();
        }

        $code->appendLine('default:');

        $code->indent++;

        $this->compileNotFound($code);

        $code->indent--;
        $code->indent--;

        $code->append('}');
    }
private function compileRouteTree(PHPCodeCollection $code, array $routeTree): void
    {
        $code->appendLine('switch (count($segments)) {');

        $code->indent++;

        foreach ($routeTree[1] as $segmentDepth => $nodes) {
            $code->appendLine('case ' . $segmentDepth . ':');

            $code->indent++;

            $segmentVariables = [];

            for ($i = 0; $i < $segmentDepth; $i++) {
                $segmentVariables[$i] = '$s' . $i;
            }

            $code->appendLine('[' . \implode(', ', $segmentVariables) . '] = $segments;');

            $this->compileSegmentNodes($code, $nodes, $segmentVariables);
            $this->compileDisallowedHttpMethodOrNotFound($code);

            $code->appendLine('break;');

            $code->indent--;

            $code->appendLine();
        }

        $code->appendLine('default:');

        $code->indent++;

        $this->compileNotFound($code);

        $code->indent--;
        $code->indent--;

        $code->append('}');
    }
Compile the counter for the segments check.

@param \Viserio\Component\Routing\TreeGenerator\PHPCodeCollection $code
@param array                                                      $routeTree