@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | $grid = $this->table(['Name:', 'Verbs:', 'Pattern:', 'Target:', 'Group:']); |
| 30 | 30 | |
| 31 | - foreach ($router->getRoutes() as $name => $route) { |
|
| 32 | - if ($route instanceof RouteInterface) { |
|
| 31 | + foreach ($router->getRoutes() as $name => $route){ |
|
| 32 | + if ($route instanceof RouteInterface){ |
|
| 33 | 33 | $grid->addRow( |
| 34 | 34 | [ |
| 35 | 35 | $name, |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | private function getRouteGroups(GroupRegistry $registry, string $routeName): array |
| 54 | 54 | { |
| 55 | 55 | $groups = []; |
| 56 | - foreach ($registry as $groupName => $group) { |
|
| 57 | - if ($group->hasRoute($routeName)) { |
|
| 56 | + foreach ($registry as $groupName => $group){ |
|
| 57 | + if ($group->hasRoute($routeName)){ |
|
| 58 | 58 | $groups[] = $groupName; |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | private function getVerbs(RouteInterface $route): string |
| 66 | 66 | { |
| 67 | - if ($route->getVerbs() === RouteInterface::VERBS) { |
|
| 67 | + if ($route->getVerbs() === RouteInterface::VERBS){ |
|
| 68 | 68 | return '*'; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $result = []; |
| 72 | - foreach ($route->getVerbs() as $verb) { |
|
| 72 | + foreach ($route->getVerbs() as $verb){ |
|
| 73 | 73 | $result[] = match (\strtolower($verb)) { |
| 74 | 74 | 'get' => '<fg=green>GET</>', |
| 75 | 75 | 'head' => '<fg=bright-green>HEAD</>', |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $pattern = \preg_replace_callback( |
| 99 | 99 | '/<([^>]*)>/', |
| 100 | 100 | static fn ($m) => \sprintf('<fg=magenta>%s</>', $m[0]), |
| 101 | - !empty($prefix) ? $prefix . '/' . \trim($pattern, '/') : $pattern |
|
| 101 | + !empty($prefix) ? $prefix.'/'.\trim($pattern, '/') : $pattern |
|
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | 104 | return $pattern; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | private function getTarget(RouteInterface $route, KernelInterface $kernel): string |
| 112 | 112 | { |
| 113 | 113 | $target = $this->getValue($route, 'target'); |
| 114 | - switch (true) { |
|
| 114 | + switch (true){ |
|
| 115 | 115 | case $target instanceof \Closure: |
| 116 | 116 | $reflection = new \ReflectionFunction($target); |
| 117 | 117 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | case $target instanceof Group: |
| 138 | 138 | $result = []; |
| 139 | - foreach ($this->getValue($target, 'controllers') as $alias => $class) { |
|
| 139 | + foreach ($this->getValue($target, 'controllers') as $alias => $class){ |
|
| 140 | 140 | $result[] = \sprintf('%s => %s', $alias, $this->relativeClass($class, $kernel)); |
| 141 | 141 | } |
| 142 | 142 | |
@@ -155,10 +155,10 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | private function getValue(object $object, string $property): mixed |
| 157 | 157 | { |
| 158 | - try { |
|
| 158 | + try{ |
|
| 159 | 159 | $r = new \ReflectionObject($object); |
| 160 | 160 | $prop = $r->getProperty($property); |
| 161 | - } catch (\Throwable $e) { |
|
| 161 | + }catch (\Throwable $e){ |
|
| 162 | 162 | return $e->getMessage(); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | { |
| 170 | 170 | $r = new \ReflectionObject($kernel); |
| 171 | 171 | |
| 172 | - if (\str_starts_with($class, $r->getNamespaceName())) { |
|
| 172 | + if (\str_starts_with($class, $r->getNamespaceName())){ |
|
| 173 | 173 | return \substr($class, \strlen($r->getNamespaceName()) + 1); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -28,8 +28,10 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | $grid = $this->table(['Name:', 'Verbs:', 'Pattern:', 'Target:', 'Group:']); |
| 30 | 30 | |
| 31 | - foreach ($router->getRoutes() as $name => $route) { |
|
| 32 | - if ($route instanceof RouteInterface) { |
|
| 31 | + foreach ($router->getRoutes() as $name => $route) |
|
| 32 | + { |
|
| 33 | + if ($route instanceof RouteInterface) |
|
| 34 | + { |
|
| 33 | 35 | $grid->addRow( |
| 34 | 36 | [ |
| 35 | 37 | $name, |
@@ -53,8 +55,10 @@ discard block |
||
| 53 | 55 | private function getRouteGroups(GroupRegistry $registry, string $routeName): array |
| 54 | 56 | { |
| 55 | 57 | $groups = []; |
| 56 | - foreach ($registry as $groupName => $group) { |
|
| 57 | - if ($group->hasRoute($routeName)) { |
|
| 58 | + foreach ($registry as $groupName => $group) |
|
| 59 | + { |
|
| 60 | + if ($group->hasRoute($routeName)) |
|
| 61 | + { |
|
| 58 | 62 | $groups[] = $groupName; |
| 59 | 63 | } |
| 60 | 64 | } |
@@ -64,12 +68,14 @@ discard block |
||
| 64 | 68 | |
| 65 | 69 | private function getVerbs(RouteInterface $route): string |
| 66 | 70 | { |
| 67 | - if ($route->getVerbs() === RouteInterface::VERBS) { |
|
| 71 | + if ($route->getVerbs() === RouteInterface::VERBS) |
|
| 72 | + { |
|
| 68 | 73 | return '*'; |
| 69 | 74 | } |
| 70 | 75 | |
| 71 | 76 | $result = []; |
| 72 | - foreach ($route->getVerbs() as $verb) { |
|
| 77 | + foreach ($route->getVerbs() as $verb) |
|
| 78 | + { |
|
| 73 | 79 | $result[] = match (\strtolower($verb)) { |
| 74 | 80 | 'get' => '<fg=green>GET</>', |
| 75 | 81 | 'head' => '<fg=bright-green>HEAD</>', |
@@ -111,7 +117,8 @@ discard block |
||
| 111 | 117 | private function getTarget(RouteInterface $route, KernelInterface $kernel): string |
| 112 | 118 | { |
| 113 | 119 | $target = $this->getValue($route, 'target'); |
| 114 | - switch (true) { |
|
| 120 | + switch (true) |
|
| 121 | + { |
|
| 115 | 122 | case $target instanceof \Closure: |
| 116 | 123 | $reflection = new \ReflectionFunction($target); |
| 117 | 124 | |
@@ -136,7 +143,8 @@ discard block |
||
| 136 | 143 | |
| 137 | 144 | case $target instanceof Group: |
| 138 | 145 | $result = []; |
| 139 | - foreach ($this->getValue($target, 'controllers') as $alias => $class) { |
|
| 146 | + foreach ($this->getValue($target, 'controllers') as $alias => $class) |
|
| 147 | + { |
|
| 140 | 148 | $result[] = \sprintf('%s => %s', $alias, $this->relativeClass($class, $kernel)); |
| 141 | 149 | } |
| 142 | 150 | |
@@ -155,10 +163,13 @@ discard block |
||
| 155 | 163 | |
| 156 | 164 | private function getValue(object $object, string $property): mixed |
| 157 | 165 | { |
| 158 | - try { |
|
| 166 | + try |
|
| 167 | + { |
|
| 159 | 168 | $r = new \ReflectionObject($object); |
| 160 | 169 | $prop = $r->getProperty($property); |
| 161 | - } catch (\Throwable $e) { |
|
| 170 | + } |
|
| 171 | + catch (\Throwable $e) |
|
| 172 | + { |
|
| 162 | 173 | return $e->getMessage(); |
| 163 | 174 | } |
| 164 | 175 | |
@@ -169,7 +180,8 @@ discard block |
||
| 169 | 180 | { |
| 170 | 181 | $r = new \ReflectionObject($kernel); |
| 171 | 182 | |
| 172 | - if (\str_starts_with($class, $r->getNamespaceName())) { |
|
| 183 | + if (\str_starts_with($class, $r->getNamespaceName())) |
|
| 184 | + { |
|
| 173 | 185 | return \substr($class, \strlen($r->getNamespaceName()) + 1); |
| 174 | 186 | } |
| 175 | 187 | |