File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,9 +12,11 @@ class Router
1212
1313 /**
1414 * A quick static function to register a route in the router. Used by the shorthand methods as well.
15+ *
1516 * @param string $route The path to be used as the route.
1617 * @param callable|string $action Either a callable to be executed, or a string reference to a method.
1718 * @param string|array $methods The HTTP verb(s) this route accepts.
19+ * @return Router
1820 */
1921 public static function add (string $ route , callable |string $ action , string |array $ methods = 'GET ' )
2022 {
@@ -52,6 +54,17 @@ public static function methodNotAllowed(callable $action)
5254 self ::$ methodNotAllowed = $ action ;
5355 }
5456
57+ /**
58+ * Redefine the default constraint for route parameters. Default is '([\w\-]+)'
59+ *
60+ * @param string $constraint The RegEx you want parameters to adhere to by default. Defaults to '([\w\-]+)'
61+ * @return void
62+ */
63+ public static function setDefaultConstraint (string $ constraint = '([\w\-]+) ' )
64+ {
65+ self ::$ defaultConstraint = $ constraint ;
66+ }
67+
5568 public static function with (string |array $ parameter , string $ constraint = '' )
5669 {
5770 if (is_array ($ parameter )) {
You can’t perform that action at this time.
0 commit comments