| @@ -38,7 +38,7 @@ discard block | ||
| 38 | 38 |      { | 
| 39 | 39 |          $this->setDescription('Display all routes in a tree display'); | 
| 40 | 40 |          $this->setHelp('List all routes in a hierarchical tree'); | 
| 41 | -        $this->addOption('space', 's', InputOption::VALUE_NONE,'display with more space'); | |
| 41 | +        $this->addOption('space', 's', InputOption::VALUE_NONE, 'display with more space'); | |
| 42 | 42 | } | 
| 43 | 43 | |
| 44 | 44 | public function execute(InputInterface $input, OutputInterface $output): int | 
| @@ -53,7 +53,7 @@ discard block | ||
| 53 | 53 | } | 
| 54 | 54 | |
| 55 | 55 | $routes = $this->router->getRoutes(); | 
| 56 | -        $sort = function (Route $a, Route $b) { | |
| 56 | +        $sort = function(Route $a, Route $b) { | |
| 57 | 57 | return $a->getPath() <=> $b->getPath(); | 
| 58 | 58 | }; | 
| 59 | 59 | usort($routes, $sort); | 
| @@ -65,7 +65,7 @@ discard block | ||
| 65 | 65 | |
| 66 | 66 |          foreach ($paths as $method => $methodPaths) { | 
| 67 | 67 | |
| 68 | - $io->info($method . ' paths:'); | |
| 68 | + $io->info($method.' paths:'); | |
| 69 | 69 | $tree = $this->buildTree($methodPaths); | 
| 70 | 70 | $method === 'GET' ? array_shift($tree) : null; | 
| 71 | 71 |              $output->writeln('/'); | 
| @@ -100,11 +100,11 @@ discard block | ||
| 100 | 100 | $totalKeys = count($keys); | 
| 101 | 101 | |
| 102 | 102 |          foreach ($keys as $index => $key) { | 
| 103 | -            if ($index === 0  && $this->spacing === true) { | |
| 104 | - $output->writeln($indent . '|'); | |
| 103 | +            if ($index === 0 && $this->spacing === true) { | |
| 104 | + $output->writeln($indent.'|'); | |
| 105 | 105 | } | 
| 106 | 106 | |
| 107 | - $output->write($indent . '|_ ' . $key); | |
| 107 | + $output->write($indent.'|_ '.$key); | |
| 108 | 108 | |
| 109 | 109 | // Check if this node has only one child, in which case we collapse it | 
| 110 | 110 | $useChild = false; | 
| @@ -112,7 +112,7 @@ discard block | ||
| 112 | 112 |              if (count($tree[$key]) == 1) { | 
| 113 | 113 | // Find the only child node and print it directly without further recursion | 
| 114 | 114 | $child = array_keys($tree[$key])[0]; | 
| 115 | - $output->write( '/' . $child); | |
| 115 | +                $output->write('/'.$child); | |
| 116 | 116 | $useChild = true; | 
| 117 | 117 | } | 
| 118 | 118 | |
| @@ -121,13 +121,13 @@ discard block | ||
| 121 | 121 | |
| 122 | 122 | // Recursively print the subtree, adjusting the indentation | 
| 123 | 123 |              if (!empty($node) && count($node) > 1) { | 
| 124 | - $newIndent = $index + 1 === $totalKeys ? $indent . ' ' : $indent . '| '; | |
| 124 | + $newIndent = $index + 1 === $totalKeys ? $indent.' ' : $indent.'| '; | |
| 125 | 125 | $this->printTree($node, $output, $newIndent); | 
| 126 | 126 | } | 
| 127 | 127 | |
| 128 | 128 | // If there's another sibling node, print '|' | 
| 129 | 129 |              if ($index < $totalKeys - 1 && $this->spacing === true) { | 
| 130 | - $output->write($indent . '| ' . "\n"); // Adjusts the visual output with proper spacing | |
| 130 | + $output->write($indent.'| '."\n"); // Adjusts the visual output with proper spacing | |
| 131 | 131 | } | 
| 132 | 132 | } | 
| 133 | 133 | } | 
| @@ -60,11 +60,11 @@ | ||
| 60 | 60 | $middlewared = $this->isMiddlewared($method, $path); | 
| 61 | 61 | |
| 62 | 62 |              if ($blocked) { | 
| 63 | - $path = '<fg=red>' .$path . '</>'; | |
| 63 | + $path = '<fg=red>' .$path . '</>'; | |
| 64 | 64 | } | 
| 65 | 65 | |
| 66 | 66 |              if ($middlewared) { | 
| 67 | - $path = '<fg=magenta>' .$path . '</>'; | |
| 67 | + $path = '<fg=magenta>' .$path . '</>'; | |
| 68 | 68 | } | 
| 69 | 69 | |
| 70 | 70 | $paths[] = [$method, $path]; | 
| @@ -47,7 +47,7 @@ discard block | ||
| 47 | 47 | } | 
| 48 | 48 | |
| 49 | 49 | $routes = $this->router->getRoutes(); | 
| 50 | -        $sort = function (Route $a, Route $b) { | |
| 50 | +        $sort = function(Route $a, Route $b) { | |
| 51 | 51 | return $a->getPath() <=> $b->getPath(); | 
| 52 | 52 | }; | 
| 53 | 53 | usort($routes, $sort); | 
| @@ -60,11 +60,11 @@ discard block | ||
| 60 | 60 | $middlewared = $this->isMiddlewared($method, $path); | 
| 61 | 61 | |
| 62 | 62 |              if ($blocked) { | 
| 63 | - $path = '<fg=red>' .$path . '</>'; | |
| 63 | + $path = '<fg=red>'.$path.'</>'; | |
| 64 | 64 | } | 
| 65 | 65 | |
| 66 | 66 |              if ($middlewared) { | 
| 67 | - $path = '<fg=magenta>' .$path . '</>'; | |
| 67 | + $path = '<fg=magenta>'.$path.'</>'; | |
| 68 | 68 | } | 
| 69 | 69 | |
| 70 | 70 | $paths[] = [$method, $path]; | 
| @@ -33,12 +33,12 @@ discard block | ||
| 33 | 33 | $factory = new ResponseFactory(); | 
| 34 | 34 | $strategy = new JsonStrategy($factory); | 
| 35 | 35 | $strategy->setContainer($c); | 
| 36 | -        $group = $this->group('/api', function (RouteGroup $route) use ($controllerClass, $urlSlug) { | |
| 37 | -            $route->map('GET', '/' . $urlSlug, [$controllerClass, 'index']); | |
| 38 | -            $route->map('POST', '/' . $urlSlug, [$controllerClass, 'create']); | |
| 39 | -            $route->map('GET', '/' . $urlSlug . '/{id}', [$controllerClass, 'read']); | |
| 40 | -            $route->map('PATCH', '/' . $urlSlug . '/{id}', [$controllerClass, 'update']); | |
| 41 | -            $route->map('DELETE', '/' . $urlSlug . '/{id}', [$controllerClass, 'delete']); | |
| 36 | +        $group = $this->group('/api', function(RouteGroup $route) use ($controllerClass, $urlSlug) { | |
| 37 | +            $route->map('GET', '/'.$urlSlug, [$controllerClass, 'index']); | |
| 38 | +            $route->map('POST', '/'.$urlSlug, [$controllerClass, 'create']); | |
| 39 | +            $route->map('GET', '/'.$urlSlug.'/{id}', [$controllerClass, 'read']); | |
| 40 | +            $route->map('PATCH', '/'.$urlSlug.'/{id}', [$controllerClass, 'update']); | |
| 41 | +            $route->map('DELETE', '/'.$urlSlug.'/{id}', [$controllerClass, 'delete']); | |
| 42 | 42 | }); | 
| 43 | 43 | $group->setStrategy($strategy); | 
| 44 | 44 | $group->middlewares([new JsonParse()]); | 
| @@ -51,15 +51,15 @@ discard block | ||
| 51 | 51 | $factory = new ResponseFactory(); | 
| 52 | 52 | $strategy = new JsonStrategy($factory); | 
| 53 | 53 | $strategy->setContainer($c); | 
| 54 | -        $group = $this->group('/admin', function (RouteGroup $route) use ($controllerClass, $urlSlug) { | |
| 55 | -            $route->map('GET', '/' . $urlSlug, [$controllerClass, 'index']); | |
| 56 | -            $route->map('GET', '/' . $urlSlug . '/create', [$controllerClass, 'create']); | |
| 57 | -            $route->map('GET', '/' . $urlSlug . '/{id}', [$controllerClass, 'view']); | |
| 58 | -            $route->map('GET', '/' . $urlSlug . '/{id}/delete', [$controllerClass, 'delete']); | |
| 59 | -            $route->map('GET', '/' . $urlSlug . '/{id}/edit', [$controllerClass, 'edit']); | |
| 60 | -            $route->map('POST', '/' . $urlSlug . '/create', [$controllerClass, 'create']); | |
| 61 | -            $route->map('POST', '/' . $urlSlug . '/{id}/delete', [$controllerClass, 'delete']); | |
| 62 | -            $route->map('POST', '/' . $urlSlug . '/{id}/edit', [$controllerClass, 'edit']); | |
| 54 | +        $group = $this->group('/admin', function(RouteGroup $route) use ($controllerClass, $urlSlug) { | |
| 55 | +            $route->map('GET', '/'.$urlSlug, [$controllerClass, 'index']); | |
| 56 | +            $route->map('GET', '/'.$urlSlug.'/create', [$controllerClass, 'create']); | |
| 57 | +            $route->map('GET', '/'.$urlSlug.'/{id}', [$controllerClass, 'view']); | |
| 58 | +            $route->map('GET', '/'.$urlSlug.'/{id}/delete', [$controllerClass, 'delete']); | |
| 59 | +            $route->map('GET', '/'.$urlSlug.'/{id}/edit', [$controllerClass, 'edit']); | |
| 60 | +            $route->map('POST', '/'.$urlSlug.'/create', [$controllerClass, 'create']); | |
| 61 | +            $route->map('POST', '/'.$urlSlug.'/{id}/delete', [$controllerClass, 'delete']); | |
| 62 | +            $route->map('POST', '/'.$urlSlug.'/{id}/edit', [$controllerClass, 'edit']); | |
| 63 | 63 | }); | 
| 64 | 64 | |
| 65 | 65 | return $group; |