Passed
Push — master ( 8d0a2c...a6fff0 )
by Dan
02:33
created
Src/Router/RouterResponse.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      * @param string $handler
101 101
      * @return RouterResponse
102 102
      */
103
-    public function withHandler(string $handler){
103
+    public function withHandler(string $handler) {
104 104
         $new = clone $this;
105 105
         $new->handler = $handler;
106 106
         return $new;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      * @param array $vars
111 111
      * @return RouterResponse
112 112
      */
113
-    public function withVars(array $vars){
113
+    public function withVars(array $vars) {
114 114
         $new = clone $this;
115 115
         $new->vars = $vars;
116 116
         return $new;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      * @param int $code
121 121
      * @return RouterResponse
122 122
      */
123
-    public function withStatusCode(int $code){
123
+    public function withStatusCode(int $code) {
124 124
         $new = clone $this;
125 125
         $new->statusCode = $code;
126 126
         return $new;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      * @param array $names
131 131
      * @return RouterResponse
132 132
      */
133
-    public function withNames(array $names){
133
+    public function withNames(array $names) {
134 134
         $new = clone $this;
135 135
         $new->names = $names;
136 136
         return $new;
Please login to merge, or discard this patch.
Src/Router/Router.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         $this->adaptor = $adaptor;
54 54
         $this->collection = $collection;
55 55
 
56
-        if (isset($options['ignoreTrailingSlash'])){
56
+        if (isset($options['ignoreTrailingSlash'])) {
57 57
             $this->ignoreTrailingSlash = (bool)$options['ignoreTrailingSlash'];
58 58
         }
59 59
 
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
         $requestUri = $request->getUri()->getPath();
69 69
 
70 70
 
71
-        if ($this->ignoreTrailingSlash === true && $requestUri !== '/'){
72
-            $requestUri = rtrim($requestUri,'/');
71
+        if ($this->ignoreTrailingSlash === true && $requestUri !== '/') {
72
+            $requestUri = rtrim($requestUri, '/');
73 73
         }
74 74
 
75 75
         return $this->adaptor->match(
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     /**
154 154
      * @param bool $ignore
155 155
      */
156
-    public function disableTrailingSlash($ignore = true){
156
+    public function disableTrailingSlash($ignore = true) {
157 157
         $this->ignoreTrailingSlash = $ignore;
158 158
     }
159 159
 }
Please login to merge, or discard this patch.
Src/Router/RouteCollection.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function addNamespace(string $namespace)
83 83
     {
84
-        $formattedNamespace = '\\'.ltrim($namespace,'\\');
84
+        $formattedNamespace = '\\' . ltrim($namespace, '\\');
85 85
         $this->namespace[] = $formattedNamespace;
86 86
     }
87 87
 
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 
231 231
         $route = \implode('', $this->group) . $routePattern;
232 232
 
233
-        if (substr($route, -1) === '/' && strlen($route) > 1){
234
-            $route = rtrim($route,'/');
233
+        if (substr($route, -1) === '/' && strlen($route) > 1) {
234
+            $route = rtrim($route, '/');
235 235
         }
236 236
 
237 237
         return $route;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
                     )
254 254
                 );
255 255
                 $new->collection[] = $addRoute;
256
-            } catch (\Exception $e) {
256
+            }catch (\Exception $e) {
257 257
                 if ($throw) {
258 258
                     throw new RouteException($e->getMessage());
259 259
                 }
Please login to merge, or discard this patch.
Src/Router/Adaptor/FastRouteAdaptor.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
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
                  */
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
             $routes = (array)require $cacheFile;
234 234
 
235 235
             foreach ($routes[0] as $routeMethod => $routeData) {
236
-                foreach ($routeData as $routePattern => $routeContent){
236
+                foreach ($routeData as $routePattern => $routeContent) {
237 237
                     $routePath = \rtrim($context, '/') . DIRECTORY_SEPARATOR . \ltrim($routePattern, '/');
238 238
                     $collection->addRoute($routeMethod, $routePath, $routeContent['content'], $routeContent['name']);
239 239
                 }
Please login to merge, or discard this patch.
Example/FastRouteExample.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 
29 29
 //Routes collections can then be added to the router:
30 30
 $routeCollection = new \Ds\Router\RouteCollection();
31
-$routeCollection->addRoute('GET','/some-path','handler::string',['routeName']);
31
+$routeCollection->addRoute('GET', '/some-path', 'handler::string', ['routeName']);
32 32
 $router->withCollection($routeCollection);
33 33
 
34 34
 $app = new \StdClass();
Please login to merge, or discard this patch.
Tests/Router/RouteCollectionTest.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
     {
41 41
         $handler = 'my-handler';
42 42
         $routes = $this->collection;
43
-        $routes->group('/path', function () use ($routes, $handler) {
43
+        $routes->group('/path', function() use ($routes, $handler) {
44 44
             $routes->addRoute(['GET', 'POST'], '/foo', $handler, ['global']);
45
-            $routes->group('/sub-dir', function () use ($routes, $handler) {
45
+            $routes->group('/sub-dir', function() use ($routes, $handler) {
46 46
                 $routes->addRoute(['GET'], '/sub-page', $handler, ['sub-dir']);
47 47
             });
48 48
         });
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     public function testMergeCollection()
183 183
     {
184 184
         $handler = 'handler::string';
185
-        $names = ['routes','names'];
185
+        $names = ['routes', 'names'];
186 186
         $collection = new RouteCollection();
187 187
         $collection->addRoute('GET', '/path', $handler, $names);
188 188
         $collection->addRoute('GET', '/another', $handler, $names);
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
     {
202 202
         $this->setExpectedException(RouteException::class);
203 203
         $handler = 'handler::string';
204
-        $names = ['routes','names'];
204
+        $names = ['routes', 'names'];
205 205
         $collection = new RouteCollection();
206 206
         $collection->addRoute('GET', '/path', $handler, $names);
207 207
         $collection->addRoute('GET', '/another', $handler, $names);
@@ -252,11 +252,11 @@  discard block
 block discarded – undo
252 252
      */
253 253
     public function testMergeGroupNames()
254 254
     {
255
-        $expected = ['route-name','group-name'];
255
+        $expected = ['route-name', 'group-name'];
256 256
         $handler = 'myhandler';
257 257
         $routes = $this->collection;
258 258
 
259
-        $routes->group('/path', function () use ($routes, $handler) {
259
+        $routes->group('/path', function() use ($routes, $handler) {
260 260
             $routes->addRoute(['GET', 'POST'], '/foo', $handler, ['route-name']);
261 261
         }, ['group-name']);
262 262
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
     /**
268 268
      * Test that the namespace is matched to the handler and returned.
269 269
      */
270
-    public function testFindHandlerNamespace(){
270
+    public function testFindHandlerNamespace() {
271 271
 
272 272
         $routeCollection = new RouteCollection();
273 273
         $routeCollection->addNamespace('\Ds\Router');
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
         $reflectionMethod->setAccessible(true);
280 280
         $actual = $reflectionMethod->invoke($routeCollection, $handler);
281 281
 
282
-        $this->assertEquals($expected,$actual);
282
+        $this->assertEquals($expected, $actual);
283 283
     }
284 284
 
285 285
     /**
286 286
      * Test that backlash is added to start of namespace on response.
287 287
      */
288
-    public function testFindHandlerNamespaceNoBacklash(){
288
+    public function testFindHandlerNamespaceNoBacklash() {
289 289
 
290 290
         $routeCollection = new RouteCollection();
291 291
         $routeCollection->addNamespace('Ds\Router');
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
         $reflectionMethod->setAccessible(true);
298 298
         $actual = $reflectionMethod->invoke($routeCollection, $handler);
299 299
 
300
-        $this->assertEquals($expected,$actual);
300
+        $this->assertEquals($expected, $actual);
301 301
     }
302 302
 
303 303
 }
Please login to merge, or discard this patch.