Total Complexity | 6 |
Total Lines | 54 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class Route |
||
12 | { |
||
13 | protected $app; |
||
14 | |||
15 | public function __construct(Suricate $app) |
||
16 | { |
||
17 | $this->app = $app; |
||
18 | } |
||
19 | |||
20 | /** |
||
21 | * Execute command |
||
22 | * |
||
23 | * @return integer |
||
24 | */ |
||
25 | public function execute(): int |
||
26 | { |
||
27 | $routes = $this->getRoutes(); |
||
28 | echo "Number of routes defined: " . count($routes) . "\n\n"; |
||
29 | |||
30 | foreach ($routes as $route) { |
||
31 | echo str_repeat("-", 80) . "\n"; |
||
32 | echo " "; |
||
33 | echo "Name: " . |
||
34 | Console::coloredString($route->getName(), 'green') . |
||
35 | "\n"; |
||
36 | echo " Methods: " . |
||
37 | str_pad(implode('|', $route->getMethod()), 20, ' '); |
||
38 | echo " | Path: "; |
||
39 | echo $route->getPath(); |
||
40 | echo "\n"; |
||
41 | echo " Parameters:\n"; |
||
42 | $parameters = $route->getParameters(); |
||
43 | if (count($parameters) === 0) { |
||
44 | echo " None\n"; |
||
45 | } else { |
||
46 | foreach ($parameters as $paramName => $paramPattern) { |
||
47 | echo " - " . $paramName . ": " . $paramPattern . "\n"; |
||
48 | } |
||
49 | } |
||
50 | |||
51 | echo " Target: " . implode('::', $route->getTarget()) . "\n"; |
||
52 | } |
||
53 | |||
54 | return 0; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Get routes defined in configuration |
||
59 | * |
||
60 | * @return array |
||
61 | */ |
||
62 | protected function getRoutes(): array |
||
65 | } |
||
66 | } |
||
67 |