@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | { |
34 | 34 | $handler = 'my-handler'; |
35 | 35 | $routes = $this->collection; |
36 | - $routes->group('/path', function () use ($routes, $handler) { |
|
36 | + $routes->group('/path', function() use ($routes, $handler) { |
|
37 | 37 | $routes->addRoute(['GET', 'POST'], '/foo', $handler, ['global']); |
38 | - $routes->group('/sub-dir', function () use ($routes, $handler) { |
|
38 | + $routes->group('/sub-dir', function() use ($routes, $handler) { |
|
39 | 39 | $routes->addRoute(['GET'], '/sub-page', $handler, ['sub-dir']); |
40 | 40 | }); |
41 | 41 | }); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | public function testMergeCollection() |
176 | 176 | { |
177 | 177 | $handler = 'handler::string'; |
178 | - $names = ['routes','names']; |
|
178 | + $names = ['routes', 'names']; |
|
179 | 179 | $collection = new RouteCollection(); |
180 | 180 | $collection->addRoute('GET', '/path', $handler, $names); |
181 | 181 | $collection->addRoute('GET', '/another', $handler, $names); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | { |
195 | 195 | $this->setExpectedException(RouteException::class); |
196 | 196 | $handler = 'handler::string'; |
197 | - $names = ['routes','names']; |
|
197 | + $names = ['routes', 'names']; |
|
198 | 198 | $collection = new RouteCollection(); |
199 | 199 | $collection->addRoute('GET', '/path', $handler, $names); |
200 | 200 | $collection->addRoute('GET', '/another', $handler, $names); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $rawPattern = '/mypattern/'; |
241 | 241 | $expectedPattern = '/' . \ltrim($rawPattern, '/'); |
242 | 242 | $expected = \implode('', $groups) . $expectedPattern; |
243 | - $expected = \rtrim($expected,'/'); |
|
243 | + $expected = \rtrim($expected, '/'); |
|
244 | 244 | |
245 | 245 | $this->assertEquals($expected, $collection->formatRoutePattern($rawPattern)); |
246 | 246 | } |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function testMergeGroupNames() |
252 | 252 | { |
253 | - $expected = ['route-name','group-name']; |
|
253 | + $expected = ['route-name', 'group-name']; |
|
254 | 254 | $handler = 'myhandler'; |
255 | 255 | $routes = $this->collection; |
256 | 256 | |
257 | - $routes->group('/path', function () use ($routes, $handler) { |
|
257 | + $routes->group('/path', function() use ($routes, $handler) { |
|
258 | 258 | $routes->addRoute(['GET', 'POST'], '/foo', $handler, ['route-name']); |
259 | 259 | }, ['group-name']); |
260 | 260 |
@@ -14,8 +14,6 @@ |
||
14 | 14 | use Ds\Router\Interfaces\RouteInterface; |
15 | 15 | use Ds\Router\Interfaces\SerializerInterface; |
16 | 16 | use Ds\Router\RouterResponse; |
17 | - |
|
18 | - |
|
19 | 17 | use Symfony\Component\Routing\Matcher\UrlMatcher; |
20 | 18 | use Symfony\Component\Routing\RequestContext; |
21 | 19 | use Symfony\Component\Routing\RouteCollection; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | public function getSymfonyRouteCollection(RouteCollectionInterface $routes) |
87 | 87 | { |
88 | 88 | |
89 | - if (!$this->options['cacheDisabled'] && file_exists($this->options['cacheFile'])){ |
|
89 | + if (!$this->options['cacheDisabled'] && file_exists($this->options['cacheFile'])) { |
|
90 | 90 | //get cached route collection. |
91 | 91 | } |
92 | 92 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | array('month' => '[0-9]{4}-[0-9]{2}'), // requirements |
100 | 100 | array(), // options |
101 | 101 | '', // host |
102 | - array('https','https'), // schemes |
|
102 | + array('https', 'https'), // schemes |
|
103 | 103 | array('GET') // methods |
104 | 104 | ); |
105 | 105 |
@@ -14,7 +14,6 @@ |
||
14 | 14 | use Ds\Router\Interfaces\RouteInterface; |
15 | 15 | use Ds\Router\Interfaces\SerializerInterface; |
16 | 16 | use Ds\Router\RouterResponse; |
17 | - |
|
18 | 17 | use Symfony\Component\Routing\Matcher\UrlMatcher; |
19 | 18 | use Symfony\Component\Routing\RequestContext; |
20 | 19 | use Symfony\Component\Routing\Route; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $this->options = $options; |
136 | 136 | |
137 | 137 | return \FastRoute\cachedDispatcher( |
138 | - function (RouteCollector $fastRouteCollector) use ($routes) { |
|
138 | + function(RouteCollector $fastRouteCollector) use ($routes) { |
|
139 | 139 | /** |
140 | 140 | * @var $route RouteInterface |
141 | 141 | */ |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | } |
229 | 229 | $routes = (array)require $cacheFile; |
230 | 230 | foreach ($routes[0] as $routeMethod => $routeData) { |
231 | - foreach ($routeData as $routePattern => $routeContent){ |
|
231 | + foreach ($routeData as $routePattern => $routeContent) { |
|
232 | 232 | $routePath = \rtrim($context, '/') . DIRECTORY_SEPARATOR . \ltrim($routePattern, '/'); |
233 | 233 | $collection->addRoute($routeMethod, $routePath, $routeContent['content'], $routeContent['name']); |
234 | 234 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | /** |
191 | 191 | * Reflect Controller construct and get parameters. |
192 | 192 | * |
193 | - * @param $controllerName |
|
193 | + * @param string $controllerName |
|
194 | 194 | * @internal |
195 | 195 | * |
196 | 196 | * @return \ReflectionParameter[] |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | /** |
322 | 322 | * Checks controller instance against whitelist. |
323 | 323 | * |
324 | - * @param $controller |
|
324 | + * @param string $controller |
|
325 | 325 | * @param $options |
326 | 326 | * @throws DispatchException |
327 | 327 | */ |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | /** |
356 | 356 | * Checks controller instance against blacklist. |
357 | 357 | * |
358 | - * @param $controller |
|
358 | + * @param string $controller |
|
359 | 359 | * @param $options |
360 | 360 | * @throws DispatchException |
361 | 361 | */ |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | case 'string': |
84 | 84 | |
85 | 85 | $params = \explode($this->options['stringHandlerPattern'], $handler); |
86 | - if (!isset($params[1])){ |
|
86 | + if (!isset($params[1])) { |
|
87 | 87 | $response = $handler; |
88 | 88 | break; |
89 | 89 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | try { |
126 | 126 | $resolvedHandler['controller'] = $this->_findClass($controllerMethod[0]); |
127 | - } catch (\Exception $e) { |
|
127 | + }catch (\Exception $e) { |
|
128 | 128 | throw new DispatchException($e->getMessage()); |
129 | 129 | } |
130 | 130 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | try { |
177 | 177 | $this->_getParamsFromVariableName($args); |
178 | - } catch (\Exception $e) { |
|
178 | + }catch (\Exception $e) { |
|
179 | 179 | $this->_getParamsFromTypeHint($args); |
180 | 180 | } |
181 | 181 | |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | protected function _callController(ServerRequestInterface $request, string $controller, string $method) |
298 | 298 | { |
299 | 299 | |
300 | - if (!class_exists($controller)){ |
|
301 | - throw new DispatchException('Unable to locate controller: '.$controller); |
|
300 | + if (!class_exists($controller)) { |
|
301 | + throw new DispatchException('Unable to locate controller: ' . $controller); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | $controllerObj = new $controller(...$this->providedArguments); |
@@ -306,13 +306,13 @@ discard block |
||
306 | 306 | try { |
307 | 307 | $this->_checkWhiteList($controller, $this->options); |
308 | 308 | $this->_checkBlackList($controller, $this->options); |
309 | - } catch (\Exception $e) { |
|
309 | + }catch (\Exception $e) { |
|
310 | 310 | unset($controllerObj); |
311 | 311 | throw new DispatchException($e->getMessage()); |
312 | 312 | } |
313 | 313 | |
314 | - if (!method_exists($controllerObj,$method)){ |
|
315 | - throw new DispatchException('Unable to locate method: '.$controller.'::'.$method); |
|
314 | + if (!method_exists($controllerObj, $method)) { |
|
315 | + throw new DispatchException('Unable to locate method: ' . $controller . '::' . $method); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | return $controllerObj->{$method}($request); |