fixed some typos

This commit is contained in:
tracer 2022-10-23 12:30:09 +02:00
parent 8a7a4a2253
commit 9cacf9ced9
1 changed files with 10 additions and 1 deletions

View File

@ -1,4 +1,11 @@
<?php <?php
/*
* Copyright (c) 2022. Micha Espey <tracer@24unix.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace App\Service; 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 * 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 function addRoute(string $name, string $route, Closure $callback): void
{ {
@ -26,6 +34,7 @@ class Router
// create regex for route: // create regex for route:
$regex = preg_replace(pattern: '/(?<={).+?(?=})/', replacement: '(.*?)', subject: $route); $regex = preg_replace(pattern: '/(?<={).+?(?=})/', replacement: '(.*?)', subject: $route);
// code below is ugly, better match including the braces // code below is ugly, better match including the braces
$regex = str_replace(search: '{', replace: '', subject: $regex); $regex = str_replace(search: '{', replace: '', subject: $regex);
$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. * Currently no 404 handling.
*/ */
public function handleRouting(): void public function handleRouting(): void