Passed
Pull Request — master (#825)
by Maxim
16:52 queued 10s
created
src/Router/src/Loader/Configurator/RoutingConfigurator.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,19 +14,19 @@
 block discarded – undo
14 14
     public function __construct(
15 15
         private readonly RouteCollection $collection,
16 16
         private readonly LoaderInterface $loader
17
-    ) {
17
+    ){
18 18
     }
19 19
 
20
-    public function import(string|array $resource, string $type = null): ImportConfigurator
20
+    public function import(string | array $resource, string $type = null): ImportConfigurator
21 21
     {
22 22
         $imported = $this->loader->load($resource, $type) ?: [];
23 23
 
24
-        if (!\is_array($imported)) {
24
+        if (!\is_array($imported)){
25 25
             return new ImportConfigurator($this->collection, $imported);
26 26
         }
27 27
 
28 28
         $mergedCollection = new RouteCollection();
29
-        foreach ($imported as $subCollection) {
29
+        foreach ($imported as $subCollection){
30 30
             $mergedCollection->addCollection($subCollection);
31 31
         }
32 32
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,12 +21,14 @@
 block discarded – undo
21 21
     {
22 22
         $imported = $this->loader->load($resource, $type) ?: [];
23 23
 
24
-        if (!\is_array($imported)) {
24
+        if (!\is_array($imported))
25
+        {
25 26
             return new ImportConfigurator($this->collection, $imported);
26 27
         }
27 28
 
28 29
         $mergedCollection = new RouteCollection();
29
-        foreach ($imported as $subCollection) {
30
+        foreach ($imported as $subCollection)
31
+        {
30 32
             $mergedCollection->addCollection($subCollection);
31 33
         }
32 34
 
Please login to merge, or discard this patch.
src/Router/src/Loader/Configurator/RouteConfigurator.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
         private readonly string $name,
32 32
         private readonly string $pattern,
33 33
         private readonly RouteCollection $collection
34
-    ) {
34
+    ){
35 35
     }
36 36
 
37 37
     public function __destruct()
38 38
     {
39
-        if ($this->target === null) {
39
+        if ($this->target === null){
40 40
             throw new TargetException(
41 41
                 \sprintf('The [%s] route has no defined target. Call one of: `controller`, `action`, 
42 42
                     `namespaced`, `groupControllers`, `callable`, `handler` methods.', $this->name)
@@ -87,21 +87,21 @@  discard block
 block discarded – undo
87 87
         return $this;
88 88
     }
89 89
 
90
-    public function action(string $controller, string|array $action, int $options = 0): self
90
+    public function action(string $controller, string | array $action, int $options = 0): self
91 91
     {
92 92
         $this->target = new Action($controller, $action, $options);
93 93
 
94 94
         return $this;
95 95
     }
96 96
 
97
-    public function callable(array|\Closure $callable): self
97
+    public function callable(array | \Closure $callable): self
98 98
     {
99 99
         $this->target = $callable;
100 100
 
101 101
         return $this;
102 102
     }
103 103
 
104
-    public function handler(TargetInterface|string $target): self
104
+    public function handler(TargetInterface | string $target): self
105 105
     {
106 106
         $this->target = $target;
107 107
 
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
         return $this;
137 137
     }
138 138
 
139
-    public function middleware(MiddlewareInterface|string|array $middleware): self
139
+    public function middleware(MiddlewareInterface | string | array $middleware): self
140 140
     {
141
-        if (!\is_array($middleware)) {
141
+        if (!\is_array($middleware)){
142 142
             $middleware = [$middleware];
143 143
         }
144 144
 
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
         return $this;
148 148
     }
149 149
 
150
-    public function methods(string|array $methods): self
150
+    public function methods(string | array $methods): self
151 151
     {
152
-        $this->methods = (array) $methods;
152
+        $this->methods = (array)$methods;
153 153
 
154 154
         return $this;
155 155
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,8 @@  discard block
 block discarded – undo
36 36
 
37 37
     public function __destruct()
38 38
     {
39
-        if ($this->target === null) {
39
+        if ($this->target === null)
40
+        {
40 41
             throw new TargetException(
41 42
                 \sprintf('The [%s] route has no defined target. Call one of: `controller`, `action`, 
42 43
                     `namespaced`, `groupControllers`, `callable`, `handler` methods.', $this->name)
@@ -138,7 +139,8 @@  discard block
 block discarded – undo
138 139
 
139 140
     public function middleware(MiddlewareInterface|string|array $middleware): self
140 141
     {
141
-        if (!\is_array($middleware)) {
142
+        if (!\is_array($middleware))
143
+        {
142 144
             $middleware = [$middleware];
143 145
         }
144 146
 
Please login to merge, or discard this patch.
src/Router/src/Loader/DelegatingLoader.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@
 block discarded – undo
10 10
 {
11 11
     public function __construct(
12 12
         private readonly LoaderRegistryInterface $registry
13
-    ) {
13
+    ){
14 14
     }
15 15
 
16 16
     public function load(mixed $resource, string $type = null): mixed
17 17
     {
18
-        if (false === $loader = $this->registry->resolve($resource, $type)) {
18
+        if (false === $loader = $this->registry->resolve($resource, $type)){
19 19
             throw new LoaderLoadException(\sprintf('Loader for type [%s] not found.', $type));
20 20
         }
21 21
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@
 block discarded – undo
15 15
 
16 16
     public function load(mixed $resource, string $type = null): mixed
17 17
     {
18
-        if (false === $loader = $this->registry->resolve($resource, $type)) {
18
+        if (false === $loader = $this->registry->resolve($resource, $type))
19
+        {
19 20
             throw new LoaderLoadException(\sprintf('Loader for type [%s] not found.', $type));
20 21
         }
21 22
 
Please login to merge, or discard this patch.
src/Router/src/Loader/LoaderRegistryInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,5 +11,5 @@
 block discarded – undo
11 11
      *
12 12
      * @param string|null $type The resource type or null if unknown
13 13
      */
14
-    public function resolve(mixed $resource, string $type = null): LoaderInterface|false;
14
+    public function resolve(mixed $resource, string $type = null): LoaderInterface | false;
15 15
 }
Please login to merge, or discard this patch.
src/Router/src/Loader/LoaderRegistry.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,15 +16,15 @@
 block discarded – undo
16 16
      */
17 17
     public function __construct(array $loaders = [])
18 18
     {
19
-        foreach ($loaders as $loader) {
19
+        foreach ($loaders as $loader){
20 20
             $this->addLoader($loader);
21 21
         }
22 22
     }
23 23
 
24
-    public function resolve(mixed $resource, string $type = null): LoaderInterface|false
24
+    public function resolve(mixed $resource, string $type = null): LoaderInterface | false
25 25
     {
26
-        foreach ($this->loaders as $loader) {
27
-            if ($loader->supports($resource, $type)) {
26
+        foreach ($this->loaders as $loader){
27
+            if ($loader->supports($resource, $type)){
28 28
                 return $loader;
29 29
             }
30 30
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,15 +16,18 @@
 block discarded – undo
16 16
      */
17 17
     public function __construct(array $loaders = [])
18 18
     {
19
-        foreach ($loaders as $loader) {
19
+        foreach ($loaders as $loader)
20
+        {
20 21
             $this->addLoader($loader);
21 22
         }
22 23
     }
23 24
 
24 25
     public function resolve(mixed $resource, string $type = null): LoaderInterface|false
25 26
     {
26
-        foreach ($this->loaders as $loader) {
27
-            if ($loader->supports($resource, $type)) {
27
+        foreach ($this->loaders as $loader)
28
+        {
29
+            if ($loader->supports($resource, $type))
30
+            {
28 31
                 return $loader;
29 32
             }
30 33
         }
Please login to merge, or discard this patch.
src/Router/src/Loader/PhpFileLoader.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     public function __construct(
17 17
         private readonly FactoryInterface $factory,
18 18
         private readonly ResolverInterface $resolver,
19
-    ) {
19
+    ){
20 20
     }
21 21
 
22 22
     /**
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function load(mixed $resource, string $type = null): RouteCollection
26 26
     {
27
-        if (!\file_exists($resource)) {
27
+        if (!\file_exists($resource)){
28 28
             throw new LoaderLoadException(\sprintf('File [%s] does not exist.', $resource));
29 29
         }
30 30
 
31
-        $load = static function (string $path) {
31
+        $load = static function (string $path){
32 32
             return include $path;
33 33
         };
34 34
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,11 +24,13 @@
 block discarded – undo
24 24
      */
25 25
     public function load(mixed $resource, string $type = null): RouteCollection
26 26
     {
27
-        if (!\file_exists($resource)) {
27
+        if (!\file_exists($resource))
28
+        {
28 29
             throw new LoaderLoadException(\sprintf('File [%s] does not exist.', $resource));
29 30
         }
30 31
 
31
-        $load = static function (string $path) {
32
+        $load = static function (string $path)
33
+        {
32 34
             return include $path;
33 35
         };
34 36
 
Please login to merge, or discard this patch.
src/Router/src/PipelineFactory.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     public function __construct(
18 18
         private readonly ContainerInterface $container,
19 19
         private readonly FactoryInterface $factory
20
-    ) {
20
+    ){
21 21
     }
22 22
 
23 23
     /**
@@ -26,27 +26,27 @@  discard block
 block discarded – undo
26 26
      */
27 27
     public function createWithMiddleware(array $middleware): Pipeline
28 28
     {
29
-        if (\count($middleware) === 1 && $middleware[0] instanceof Pipeline) {
29
+        if (\count($middleware) === 1 && $middleware[0] instanceof Pipeline){
30 30
             return $middleware[0];
31 31
         }
32 32
 
33 33
         $pipeline = $this->factory->make(Pipeline::class);
34 34
         \assert($pipeline instanceof Pipeline);
35 35
 
36
-        foreach ($middleware as $item) {
37
-            if ($item instanceof MiddlewareInterface) {
36
+        foreach ($middleware as $item){
37
+            if ($item instanceof MiddlewareInterface){
38 38
                 $pipeline->pushMiddleware($item);
39
-            } elseif (\is_string($item)) {
39
+            } elseif (\is_string($item)){
40 40
                 $item = $this->container->get($item);
41 41
                 \assert($item instanceof MiddlewareInterface);
42 42
 
43 43
                 $pipeline->pushMiddleware($item);
44
-            } elseif ($item instanceof Autowire) {
44
+            } elseif ($item instanceof Autowire){
45 45
                 $item = $item->resolve($this->factory);
46 46
                 \assert($item instanceof MiddlewareInterface);
47 47
 
48 48
                 $pipeline->pushMiddleware($item);
49
-            } else {
49
+            }else{
50 50
                 $name = get_debug_type($item);
51 51
                 throw new RouteException(\sprintf('Invalid middleware `%s`', $name));
52 52
             }
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,27 +26,36 @@
 block discarded – undo
26 26
      */
27 27
     public function createWithMiddleware(array $middleware): Pipeline
28 28
     {
29
-        if (\count($middleware) === 1 && $middleware[0] instanceof Pipeline) {
29
+        if (\count($middleware) === 1 && $middleware[0] instanceof Pipeline)
30
+        {
30 31
             return $middleware[0];
31 32
         }
32 33
 
33 34
         $pipeline = $this->factory->make(Pipeline::class);
34 35
         \assert($pipeline instanceof Pipeline);
35 36
 
36
-        foreach ($middleware as $item) {
37
-            if ($item instanceof MiddlewareInterface) {
37
+        foreach ($middleware as $item)
38
+        {
39
+            if ($item instanceof MiddlewareInterface)
40
+            {
38 41
                 $pipeline->pushMiddleware($item);
39
-            } elseif (\is_string($item)) {
42
+            }
43
+            elseif (\is_string($item))
44
+            {
40 45
                 $item = $this->container->get($item);
41 46
                 \assert($item instanceof MiddlewareInterface);
42 47
 
43 48
                 $pipeline->pushMiddleware($item);
44
-            } elseif ($item instanceof Autowire) {
49
+            }
50
+            elseif ($item instanceof Autowire)
51
+            {
45 52
                 $item = $item->resolve($this->factory);
46 53
                 \assert($item instanceof MiddlewareInterface);
47 54
 
48 55
                 $pipeline->pushMiddleware($item);
49
-            } else {
56
+            }
57
+            else
58
+            {
50 59
                 $name = get_debug_type($item);
51 60
                 throw new RouteException(\sprintf('Invalid middleware `%s`', $name));
52 61
             }
Please login to merge, or discard this patch.
src/Router/src/AbstractRoute.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     public function __construct(
21 21
         protected string $pattern,
22 22
         array $defaults = []
23
-    ) {
23
+    ){
24 24
         $this->defaults = $defaults;
25 25
     }
26 26
 
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 
40 40
     public function match(Request $request): ?static
41 41
     {
42
-        if (!\in_array(\strtoupper($request->getMethod()), $this->getVerbs(), true)) {
42
+        if (!\in_array(\strtoupper($request->getMethod()), $this->getVerbs(), true)){
43 43
             return null;
44 44
         }
45 45
 
46 46
         $matches = $this->uriHandler->match($request->getUri(), $this->defaults);
47
-        if ($matches === null) {
47
+        if ($matches === null){
48 48
             return null;
49 49
         }
50 50
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,12 +39,14 @@
 block discarded – undo
39 39
 
40 40
     public function match(Request $request): ?static
41 41
     {
42
-        if (!\in_array(\strtoupper($request->getMethod()), $this->getVerbs(), true)) {
42
+        if (!\in_array(\strtoupper($request->getMethod()), $this->getVerbs(), true))
43
+        {
43 44
             return null;
44 45
         }
45 46
 
46 47
         $matches = $this->uriHandler->match($request->getUri(), $this->defaults);
47
-        if ($matches === null) {
48
+        if ($matches === null)
49
+        {
48 50
             return null;
49 51
         }
50 52
 
Please login to merge, or discard this patch.
src/Router/src/Router.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
         private readonly UriHandler $uriHandler,
46 46
         private readonly ContainerInterface $container,
47 47
         private readonly ?EventDispatcherInterface $eventDispatcher = null
48
-    ) {
49
-        $this->basePath = '/' . \ltrim($basePath, '/');
48
+    ){
49
+        $this->basePath = '/'.\ltrim($basePath, '/');
50 50
     }
51 51
 
52 52
     /**
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
     {
58 58
         $this->eventDispatcher?->dispatch(new Routing($request));
59 59
 
60
-        try {
60
+        try{
61 61
             $route = $this->matchRoute($request, $routeName);
62
-        } catch (RouteException $e) {
62
+        }catch (RouteException $e){
63 63
             throw new RouterException('Invalid route definition', $e->getCode(), $e);
64 64
         }
65 65
 
66
-        if ($route === null) {
66
+        if ($route === null){
67 67
             $this->eventDispatcher?->dispatch(new RouteNotFound($request));
68 68
             throw new RouteNotFoundException($request->getUri());
69 69
         }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
     public function getRoute(string $name): RouteInterface
93 93
     {
94
-        if (isset($this->routes[$name])) {
94
+        if (isset($this->routes[$name])){
95 95
             return $this->routes[$name];
96 96
         }
97 97
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 
101 101
     public function getRoutes(): array
102 102
     {
103
-        if (!empty($this->default)) {
103
+        if (!empty($this->default)){
104 104
             return $this->routes + [null => $this->default];
105 105
         }
106 106
 
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
 
110 110
     public function uri(string $route, iterable $parameters = []): UriInterface
111 111
     {
112
-        try {
112
+        try{
113 113
             return $this->getRoute($route)->uri($parameters);
114
-        } catch (UndefinedRouteException) {
114
+        }catch (UndefinedRouteException){
115 115
             //In some cases route name can be provided as controller:action pair, we can try to
116 116
             //generate such route automatically based on our default/fallback route
117 117
             return $this->castRoute($route)->uri($parameters);
@@ -123,31 +123,31 @@  discard block
 block discarded – undo
123 123
         /** @var GroupRegistry $groups */
124 124
         $groups = $this->container->get(GroupRegistry::class);
125 125
 
126
-        foreach ($routes->getCollection() as $name => $configurator) {
126
+        foreach ($routes->getCollection() as $name => $configurator){
127 127
             $target = $configurator->target;
128
-            if ($configurator->core !== null && $target instanceof AbstractTarget) {
128
+            if ($configurator->core !== null && $target instanceof AbstractTarget){
129 129
                 $target = $target->withCore($configurator->core);
130 130
             }
131 131
 
132 132
             $route = new Route(
133
-                $configurator->prefix . '/' . \ltrim($configurator->pattern, '/'),
133
+                $configurator->prefix.'/'.\ltrim($configurator->pattern, '/'),
134 134
                 $target,
135 135
                 $configurator->defaults
136 136
             );
137 137
 
138
-            if ($configurator->middleware !== null) {
138
+            if ($configurator->middleware !== null){
139 139
                 $route = $route->withMiddleware(...$configurator->middleware);
140 140
             }
141 141
 
142
-            if ($configurator->methods !== null) {
142
+            if ($configurator->methods !== null){
143 143
                 $route = $route->withVerbs(...$configurator->methods);
144 144
             }
145 145
 
146
-            if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME) {
146
+            if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME){
147 147
                 $groups->getGroup($configurator->group ?? $groups->getDefaultGroup())->addRoute($name, $route);
148 148
             }
149 149
 
150
-            if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME) {
150
+            if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME){
151 151
                 $this->setDefault($route);
152 152
             }
153 153
         }
@@ -158,17 +158,17 @@  discard block
 block discarded – undo
158 158
      */
159 159
     protected function matchRoute(ServerRequestInterface $request, string &$routeName = null): ?RouteInterface
160 160
     {
161
-        foreach ($this->routes as $name => $route) {
161
+        foreach ($this->routes as $name => $route){
162 162
             // Matched route will return new route instance with matched parameters
163 163
             $matched = $route->match($request);
164 164
 
165
-            if ($matched !== null) {
165
+            if ($matched !== null){
166 166
                 $routeName = $name;
167 167
                 return $matched;
168 168
             }
169 169
         }
170 170
 
171
-        if ($this->default !== null) {
171
+        if ($this->default !== null){
172 172
             return $this->default->match($request);
173 173
         }
174 174
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      */
182 182
     protected function configure(RouteInterface $route): RouteInterface
183 183
     {
184
-        if ($route instanceof ContainerizedInterface && !$route->hasContainer()) {
184
+        if ($route instanceof ContainerizedInterface && !$route->hasContainer()){
185 185
             // isolating route in a given container
186 186
             $route = $route->withContainer($this->container);
187 187
         }
@@ -205,17 +205,17 @@  discard block
 block discarded – undo
205 205
                 $route,
206 206
                 $matches
207 207
             )
208
-        ) {
208
+        ){
209 209
             throw new UndefinedRouteException(
210 210
                 "Unable to locate route or use default route with 'name/controller:action' pattern"
211 211
             );
212 212
         }
213 213
 
214
-        if (!empty($matches['name'])) {
214
+        if (!empty($matches['name'])){
215 215
             $routeObject = $this->getRoute($matches['name']);
216
-        } elseif ($this->default !== null) {
216
+        } elseif ($this->default !== null){
217 217
             $routeObject = $this->default;
218
-        } else {
218
+        }else{
219 219
             throw new UndefinedRouteException(\sprintf('Unable to locate route candidate for `%s`', $route));
220 220
         }
221 221
 
Please login to merge, or discard this patch.
Braces   +44 added lines, -20 removed lines patch added patch discarded remove patch
@@ -57,13 +57,17 @@  discard block
 block discarded – undo
57 57
     {
58 58
         $this->eventDispatcher?->dispatch(new Routing($request));
59 59
 
60
-        try {
60
+        try
61
+        {
61 62
             $route = $this->matchRoute($request, $routeName);
62
-        } catch (RouteException $e) {
63
+        }
64
+        catch (RouteException $e)
65
+        {
63 66
             throw new RouterException('Invalid route definition', $e->getCode(), $e);
64 67
         }
65 68
 
66
-        if ($route === null) {
69
+        if ($route === null)
70
+        {
67 71
             $this->eventDispatcher?->dispatch(new RouteNotFound($request));
68 72
             throw new RouteNotFoundException($request->getUri());
69 73
         }
@@ -91,7 +95,8 @@  discard block
 block discarded – undo
91 95
 
92 96
     public function getRoute(string $name): RouteInterface
93 97
     {
94
-        if (isset($this->routes[$name])) {
98
+        if (isset($this->routes[$name]))
99
+        {
95 100
             return $this->routes[$name];
96 101
         }
97 102
 
@@ -100,7 +105,8 @@  discard block
 block discarded – undo
100 105
 
101 106
     public function getRoutes(): array
102 107
     {
103
-        if (!empty($this->default)) {
108
+        if (!empty($this->default))
109
+        {
104 110
             return $this->routes + [null => $this->default];
105 111
         }
106 112
 
@@ -109,9 +115,12 @@  discard block
 block discarded – undo
109 115
 
110 116
     public function uri(string $route, iterable $parameters = []): UriInterface
111 117
     {
112
-        try {
118
+        try
119
+        {
113 120
             return $this->getRoute($route)->uri($parameters);
114
-        } catch (UndefinedRouteException) {
121
+        }
122
+        catch (UndefinedRouteException)
123
+        {
115 124
             //In some cases route name can be provided as controller:action pair, we can try to
116 125
             //generate such route automatically based on our default/fallback route
117 126
             return $this->castRoute($route)->uri($parameters);
@@ -123,9 +132,11 @@  discard block
 block discarded – undo
123 132
         /** @var GroupRegistry $groups */
124 133
         $groups = $this->container->get(GroupRegistry::class);
125 134
 
126
-        foreach ($routes->getCollection() as $name => $configurator) {
135
+        foreach ($routes->getCollection() as $name => $configurator)
136
+        {
127 137
             $target = $configurator->target;
128
-            if ($configurator->core !== null && $target instanceof AbstractTarget) {
138
+            if ($configurator->core !== null && $target instanceof AbstractTarget)
139
+            {
129 140
                 $target = $target->withCore($configurator->core);
130 141
             }
131 142
 
@@ -135,19 +146,23 @@  discard block
 block discarded – undo
135 146
                 $configurator->defaults
136 147
             );
137 148
 
138
-            if ($configurator->middleware !== null) {
149
+            if ($configurator->middleware !== null)
150
+            {
139 151
                 $route = $route->withMiddleware(...$configurator->middleware);
140 152
             }
141 153
 
142
-            if ($configurator->methods !== null) {
154
+            if ($configurator->methods !== null)
155
+            {
143 156
                 $route = $route->withVerbs(...$configurator->methods);
144 157
             }
145 158
 
146
-            if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME) {
159
+            if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME)
160
+            {
147 161
                 $groups->getGroup($configurator->group ?? $groups->getDefaultGroup())->addRoute($name, $route);
148 162
             }
149 163
 
150
-            if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME) {
164
+            if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME)
165
+            {
151 166
                 $this->setDefault($route);
152 167
             }
153 168
         }
@@ -158,17 +173,20 @@  discard block
 block discarded – undo
158 173
      */
159 174
     protected function matchRoute(ServerRequestInterface $request, string &$routeName = null): ?RouteInterface
160 175
     {
161
-        foreach ($this->routes as $name => $route) {
176
+        foreach ($this->routes as $name => $route)
177
+        {
162 178
             // Matched route will return new route instance with matched parameters
163 179
             $matched = $route->match($request);
164 180
 
165
-            if ($matched !== null) {
181
+            if ($matched !== null)
182
+            {
166 183
                 $routeName = $name;
167 184
                 return $matched;
168 185
             }
169 186
         }
170 187
 
171
-        if ($this->default !== null) {
188
+        if ($this->default !== null)
189
+        {
172 190
             return $this->default->match($request);
173 191
         }
174 192
 
@@ -181,7 +199,8 @@  discard block
 block discarded – undo
181 199
      */
182 200
     protected function configure(RouteInterface $route): RouteInterface
183 201
     {
184
-        if ($route instanceof ContainerizedInterface && !$route->hasContainer()) {
202
+        if ($route instanceof ContainerizedInterface && !$route->hasContainer())
203
+        {
185 204
             // isolating route in a given container
186 205
             $route = $route->withContainer($this->container);
187 206
         }
@@ -211,11 +230,16 @@  discard block
 block discarded – undo
211 230
             );
212 231
         }
213 232
 
214
-        if (!empty($matches['name'])) {
233
+        if (!empty($matches['name']))
234
+        {
215 235
             $routeObject = $this->getRoute($matches['name']);
216
-        } elseif ($this->default !== null) {
236
+        }
237
+        elseif ($this->default !== null)
238
+        {
217 239
             $routeObject = $this->default;
218
-        } else {
240
+        }
241
+        else
242
+        {
219 243
             throw new UndefinedRouteException(\sprintf('Unable to locate route candidate for `%s`', $route));
220 244
         }
221 245
 
Please login to merge, or discard this patch.