src/Routing/Route.php
private function compileRegex()
    {
        // Prepend the prefix
        $path = $this->prefix . $this->path;

        $asserts = $this->asserts;

        // Replace placeholders in curly braces with named regex groups
        $callback = function ($matches) use ($asserts) {
            $name = $matches[1];
            $pattern = isset($asserts[$name]) ? $asserts[$name] : ".+";

            return "(?<$name>$pattern)";
        };

        $pattern = preg_replace_callback('/{([^}]+)}/', $callback, $path);

        // Avoid double slashes
        $pattern = preg_replace('/\/+/', '/', $pattern);

        // Escape slashes, used as delimiter in regex
        $pattern = str_replace('/', '\\/', $pattern);

        // Add start and and delimiters
        return "/^$pattern$/";
    }
private function compileRegex()
    {
        // Prepend the prefix
        $path = $this->prefix . $this->path;

        $asserts = $this->asserts;

        // Replace placeholders in curly braces with named regex groups
        $callback = function ($matches) use ($asserts) {
            $name = $matches[1];
            $pattern = isset($asserts[$name]) ? $asserts[$name] : ".+";

            return "(?<$name>$pattern)";
        };

        $pattern = preg_replace_callback('/{([^}]+)}/', $callback, $path);

        // Avoid double slashes
        $pattern = preg_replace('/\/+/', '/', $pattern);

        // Escape slashes, used as delimiter in regex
        $pattern = str_replace('/', '\\/', $pattern);

        // Add start and and delimiters
        return "/^$pattern$/";
    }
private function compileRegex ( ) { // Prepend the prefix $ path = $ this -> prefix . $ this -> path ; $ asserts = $ this -> asserts ; // Replace placeholders in curly braces with named regex groups $ callback = function ( $ matches ) use ( $ asserts ) { $ name = $ matches [ 1 ] ; $ pattern = isset ( $ asserts [ $ name ] ) ? $ asserts [ $ name ] : ".+" ; return "(?<$name>$pattern)" ; } ; $ pattern = preg_replace_callback ( '/{([^}]+)}/' , $ callback , $ path ) ; // Avoid double slashes $ pattern = preg_replace ( '/\/+/' , '/' , $ pattern ) ; // Escape slashes, used as delimiter in regex $ pattern = str_replace ( '/' , '\\/' , $ pattern ) ; // Add start and and delimiters return "/^$pattern$/" ; }
Compiles a regex pattern which matches this route.
Compiles a regex pattern which matches this route .