Completed
Push — master ( 67b45a...83bc69 )
by Charis
04:26
created
src/Router.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      * setcachePool function.
179 179
      *
180 180
      * @access public
181
-     * @param CacheInterface $cachePool
181
+     * @param CacheItemPoolInterface $cachePool
182 182
      * @return Router
183 183
      */
184 184
     public function setCachePool(CacheItemPoolInterface $cachePool)
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
      * cacheAble function.
307 307
      *
308 308
      * @access protected
309
-     * @return void
309
+     * @return boolean
310 310
      */
311 311
     protected function cacheAble()
312 312
     {
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      * @access public
156 156
      * @param mixed $parser
157 157
      */
158
-    public function __construct($parser)
158
+    public function __construct ($parser)
159 159
     {
160 160
         $this->parser = $parser ?: new StdParser;
161 161
     }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
      * @param Dispatcher $dispatcher
168 168
      * @return Router
169 169
      */
170
-    public function setDispatcher(Dispatcher $dispatcher)
170
+    public function setDispatcher (Dispatcher $dispatcher)
171 171
     {
172 172
         $this->dispatcher = $dispatcher;
173 173
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      * @param CacheInterface $cachePool
182 182
      * @return Router
183 183
      */
184
-    public function setCachePool(CacheItemPoolInterface $cachePool)
184
+    public function setCachePool (CacheItemPoolInterface $cachePool)
185 185
     {
186 186
         $this->cachePool = $cachePool;
187 187
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      * @param int $cacheTtl
196 196
      * @return Router
197 197
      */
198
-    public function setCacheTtl(int $cacheTtl)
198
+    public function setCacheTtl (int $cacheTtl)
199 199
     {
200 200
         $this->cacheTtl = $cacheTtl;
201 201
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
      * @param string $cacheKey
210 210
      * @return Router
211 211
      */
212
-    public function setCacheKey(string $cacheKey)
212
+    public function setCacheKey (string $cacheKey)
213 213
     {
214 214
         $this->cacheKey = $cacheKey;
215 215
         return $this;
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
      * @param string $identifier
223 223
      * @return null|Route
224 224
      */
225
-    public function getRoute(string $identifier)
225
+    public function getRoute (string $identifier)
226 226
     {
227 227
         return !empty($this->routes[$identifier]) ? $this->routes[$identifier] : null;
228 228
     }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      * @access public
234 234
      * @return array
235 235
      */
236
-    public function getRoutes()
236
+    public function getRoutes ()
237 237
     {
238 238
         return $this->routes;
239 239
     }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
      * @param array $routes
247 247
      * @return Router
248 248
      */
249
-    public function setRoutes(array $method, array $routes)
249
+    public function setRoutes (array $method, array $routes)
250 250
     {
251 251
         foreach ($routes as $pattern => $handler) {
252 252
             $this->map($method, $pattern, $handler);
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
      * @access public
262 262
      * @return void
263 263
      */
264
-    public function getResult()
264
+    public function getResult ()
265 265
     {
266 266
         return $this->dispatch_result;
267 267
     }
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
     /**
270 270
      * {@inheritdoc}
271 271
      */
272
-    public function map($method, string $pattern, $handler)
272
+    public function map ($method, string $pattern, $handler)
273 273
     {
274 274
         $method = is_array($method) ? $method : [$method];
275 275
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
      * @param mixed $handler
298 298
      * @return Route Route
299 299
      */
300
-    protected function createRoute(string $method, string $pattern, $handler)
300
+    protected function createRoute (string $method, string $pattern, $handler)
301 301
     {
302 302
         return new Route($method, $pattern, $handler, $this->routeGroup, 'route_' . $this->routeCount);
303 303
     }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
      * @access protected
309 309
      * @return void
310 310
      */
311
-    protected function cacheAble()
311
+    protected function cacheAble ()
312 312
     {
313 313
         return !empty($this->cachePool) && !empty($this->cacheKey);
314 314
     }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
      * @access protected
320 320
      * @return CacheItemInterface
321 321
      */
322
-    protected function getCacheItem()
322
+    protected function getCacheItem ()
323 323
     {
324 324
         return $this->cacheAble() ? $this->cachePool->getItem($this->cacheKey) : new \Resilient\Dummy\CacheItem();
325 325
     }
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      * @param CacheItemInterface $cacheItem
332 332
      * @return boolean
333 333
      */
334
-    protected function saveCacheItem(CacheItemInterface $cacheItem)
334
+    protected function saveCacheItem (CacheItemInterface $cacheItem)
335 335
     {
336 336
         if ($cacheItem instanceof \Resilient\Dummy\CacheItem) {
337 337
             return false;
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
      * @param array $options (default: [])
353 353
      * @return Dispatcher
354 354
      */
355
-    protected function routeDispatcher(callable $routeDefinitionCallback, array $options = [])
355
+    protected function routeDispatcher (callable $routeDefinitionCallback, array $options = [])
356 356
     {
357 357
         $options += [
358 358
             'routeParser' => 'FastRoute\\RouteParser\\Std',
@@ -387,13 +387,13 @@  discard block
 block discarded – undo
387 387
      * @access protected
388 388
      * @return Dispatcher
389 389
      */
390
-    protected function createDispatcher()
390
+    protected function createDispatcher ()
391 391
     {
392 392
         if ($this->dispatcher) {
393 393
             return $this->dispatcher;
394 394
         }
395 395
 
396
-        $this->dispatcher = $this->routeDispatcher(function (RouteCollector $r) {
396
+        $this->dispatcher = $this->routeDispatcher(function(RouteCollector $r) {
397 397
             foreach ($this->getRoutes() as $route) {
398 398
                 $r->addRoute($route->getMethod(), $route->getPattern(), $route->getIdentifier());
399 399
             }
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
      * @param string $method (default: 'GET')
413 413
      * @return Route Handling Method
414 414
      */
415
-    public function dispatch(UriInterface $uri, $method = 'GET')
415
+    public function dispatch (UriInterface $uri, $method = 'GET')
416 416
     {
417 417
         $this->dispatch_result = $this->createDispatcher()->dispatch(
418 418
             $method,
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
         return $this->handleException($handling[0], $handling[1], $handling[2]);
444 444
     }
445 445
 
446
-    protected function handleException(string $handler, array $args, string $message)
446
+    protected function handleException (string $handler, array $args, string $message)
447 447
     {
448 448
         if ($this->hasMethod($handler)) {
449 449
             return $this->$handler(...$args);
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
      * @param callable $callable
460 460
      * @return Router
461 461
      */
462
-    public function whenNotFound(callable $callable)
462
+    public function whenNotFound (callable $callable)
463 463
     {
464 464
         $this->bind($this->notFoundFuncName, $callable);
465 465
 
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
      * @param callable $callable
474 474
      * @return Router
475 475
      */
476
-    public function whenForbidden(callable $callable)
476
+    public function whenForbidden (callable $callable)
477 477
     {
478 478
         $this->bind($this->forbiddenFuncName, $callable);
479 479
 
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
      * @param mixed $args
489 489
      * @return void
490 490
      */
491
-    protected function routerRoutine($identifier, $args)
491
+    protected function routerRoutine ($identifier, $args)
492 492
     {
493 493
         $route = $this->getRoute($identifier);
494 494
 
Please login to merge, or discard this patch.