From e9fd8e153d77e14b84880e03f7e90130ff34f822 Mon Sep 17 00:00:00 2001
From: tracer <tracer@24unix.net>
Date: Sun, 23 Oct 2022 12:11:57 +0200
Subject: [PATCH] Added some small notes.

---
 src/Service/Router.php | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/Service/Router.php b/src/Service/Router.php
index 054d8a4..0e6dec6 100644
--- a/src/Service/Router.php
+++ b/src/Service/Router.php
@@ -6,6 +6,11 @@ namespace App\Service;
 use App\Entity\Route;
 use Closure;
 
+/*
+ * A small router implementation for the address book demo.
+ * Currently it doesn't handle GET requests, as not needed.
+ * But if I reuse the code in my bind Api I'll enable GET as well.
+ */
 class Router
 {
     private array $routes;
@@ -31,12 +36,16 @@ class Router
         $this->routes[] = $route;
     }
 
+    /*
+     * Check is there is a known route and executed the callback.
+     * Currently no 404 handling.
+     */
     public function handleRouting(): void
     {
         $requestUri = $_SERVER['REQUEST_URI'];
 
         foreach ($this->routes as $route) {
-            if (preg_match(pattern:  $route->getRegex(), subject: $requestUri, matches: $matches)) {
+            if (preg_match(pattern: $route->getRegex(), subject: $requestUri, matches: $matches)) {
                 $parameters = [];
                 foreach ($route->getParameters() as $id => $parameter) {
                     $parameters[$parameter] = $matches[$id +1];
@@ -48,6 +57,7 @@ class Router
                 return;
             }
         }
+        // Throw a 404 result later …
         die("Invalid route: $requestUri");
     }
 }
\ No newline at end of file