diff --git a/src/Service/Router.php b/src/Service/Router.php index 0e6dec6..b501c78 100644 --- a/src/Service/Router.php +++ b/src/Service/Router.php @@ -1,4 +1,11 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + */ namespace App\Service; @@ -17,6 +24,7 @@ class Router /* * This method takes a route like /admin/users/{user} and creates a regex to match on call + * More complex routes as /posts/{thread}/show/{page} are supported as well. */ function addRoute(string $name, string $route, Closure $callback): void { @@ -26,6 +34,7 @@ class Router // create regex for route: $regex = preg_replace(pattern: '/(?<={).+?(?=})/', replacement: '(.*?)', subject: $route); + // code below is ugly, better match including the braces $regex = str_replace(search: '{', replace: '', subject: $regex); $regex = str_replace(search: '}', replace: '', subject: $regex); @@ -37,7 +46,7 @@ class Router } /* - * Check is there is a known route and executed the callback. + * Check if there is a known route and executes the callback. * Currently no 404 handling. */ public function handleRouting(): void