public function url(string $routeName, array $parameters = []): ?string
    {
        if (isset($this->names[$routeName]) == false) {
            return null;
        }

        $uri = $this->names[$routeName]->getUri();

        foreach ($parameters as $name => $value) {
            $uri = preg_replace('/\??\{'.$name.'\??\}/', $value, $uri);
        }

        $uri = preg_replace('/{[^\}]+\?\}/', '', $uri);
        $uri = str_replace('/?', '', $uri);

        return $uri;
    }
public function url(string $routeName, array $parameters = []): ?string
    {
        if (isset($this->names[$routeName]) == false) {
            return null;
        }

        $uri = $this->names[$routeName]->getUri();

        foreach ($parameters as $name => $value) {
            $uri = preg_replace('/\??\{'.$name.'\??\}/', $value, $uri);
        }

        $uri = preg_replace('/{[^\}]+\?\}/', '', $uri);
        $uri = str_replace('/?', '', $uri);

        return $uri;
    }
public function url ( string $ routeName , array $ parameters = [ ] ) : ? string { if ( isset ( $ this -> names [ $ routeName ] ) == false ) { return null ; } $ uri = $ this -> names [ $ routeName ] -> getUri ( ) ; foreach ( $ parameters as $ name => $ value ) { $ uri = preg_replace ( '/\??\{' . $ name . '\??\}/' , $ value , $ uri ) ; } $ uri = preg_replace ( '/{[^\}]+\?\}/' , '' , $ uri ) ; $ uri = str_replace ( '/?' , '' , $ uri ) ; return $ uri ; }
Generate URL for given route name
It returns Null if route with given name is not found.

@param string $routeName
@param string[] $parameters
@return string|null
Generate URL for given route name It returns Null if route with given name is not found .