From 84dddd824b2f7171595c28fbe2a208629c4ec994 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Tue, 4 Feb 2025 14:56:59 -0500 Subject: [PATCH] addRoutes --- tests/test.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/test.php b/tests/test.php index ee3c66d..2a5859a 100644 --- a/tests/test.php +++ b/tests/test.php @@ -70,11 +70,7 @@ $testRoutes = [ }], ]; -$routes = array_map(function($route) use (&$routes) { - [$method, $path, $handler] = $route; - SegmentRouter::add($routes, $method, $path, $handler); - return [$method, $path, $handler]; -}, $testRoutes); +$routes = addRoutes($testRoutes); for ($i = 0; $i < 10; $i++) { @@ -130,6 +126,15 @@ function readAndAddRoutes(string $file, &$routes): array }, file($file)); } +function addRoutes($routes): array +{ + return array_map(function($route) use (&$routes) { + [$method, $path, $handler] = $route; + SegmentRouter::add($routes, $method, $path, $handler); + return [$method, $path, $handler]; + }, $routes); +} + function runIterations(int $iterations, &$routes, array $routesList) { echo "\nšŸš€ Running $iterations iterations...\n";