Completed
Push — master ( a1a0e3...df9205 )
by Ronnie
02:18
created
src/Router/Application.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
     RouteFileParser $routeFileParser = null,
51 51
     Cacher $cacher = null,
52 52
     $cacheKey = null 
53
-  ){
53
+  ) {
54 54
     $this->routeFileParser = $routeFileParser ?: new RegexRouteFileParser;
55 55
     $this->dispatcher = $dispatcher;
56 56
     $this->cacher = $cacher;
57
-    if($this->cacher) {
57
+    if ($this->cacher) {
58 58
       $this->cacheKey = $cacheKey ?: '__routeCache';  
59 59
       $this->cacheInUse = true;
60 60
     }
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
    */
68 68
   public function handle(
69 69
     $routesFile
70
-  ){
71
-    if($this->cacheInUse) {
70
+  ) {
71
+    if ($this->cacheInUse) {
72 72
       $routeData = $this->cacher->get($this->cacheKey);  
73
-      if($routeData === false) {
73
+      if ($routeData === false) {
74 74
         $routeData = $this->routeFileParser->digest($routesFile);
75 75
         $this->cacher->set($this->cacheKey, $routeData);
76 76
       }  
Please login to merge, or discard this patch.
src/Dispatcher/Regex.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,6 +38,6 @@
 block discarded – undo
38 38
       return self::NOT_FOUND;
39 39
     }
40 40
 
41
-   return preg_match($routesData[$this->verb], $this->uri) ? self::FOUND : self::NOT_FOUND;
41
+    return preg_match($routesData[$this->verb], $this->uri) ? self::FOUND : self::NOT_FOUND;
42 42
   }
43 43
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
   public function __construct(
22 22
     $verb,
23 23
     $uri
24
-  ){
24
+  ) {
25 25
     $this->verb = $verb;
26 26
     $this->uri = $uri;
27 27
   }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
    */
35 35
   public function dispatch($routesData)
36 36
   {
37
-    if(empty($routesData)) {
37
+    if (empty($routesData)) {
38 38
       return self::NOT_FOUND;
39 39
     }
40 40
 
Please login to merge, or discard this patch.
src/RouteFileParser/Regex.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
    * @param int $index
63 63
    */
64 64
   private function setRouteRegexData(&$routeRegexes, &$routesData, $index) {
65
-     if(isset($routeRegexes[$routesData[$index][self::VERB]]) === false) {
65
+      if(isset($routeRegexes[$routesData[$index][self::VERB]]) === false) {
66 66
         $routeRegexes[$routesData[$index][self::VERB]] = self::REGEX_PREFIX;
67 67
       }
68 68
   }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
   {
24 24
     $routesData = $this->getRoutesData($file);
25 25
     $routeRegexes = [];
26
-    for($i = 0; $i < count($routesData) -1; ++$i) {
26
+    for ($i = 0; $i < count($routesData)-1; ++$i) {
27 27
       $this->setRouteRegexData($routeRegexes, $routesData, $i);
28
-      $routeRegexes[$routesData[$i][self::VERB]] .= $routesData[$i][self::URI] . self::REGEX_SEPARATOR;
28
+      $routeRegexes[$routesData[$i][self::VERB]] .= $routesData[$i][self::URI].self::REGEX_SEPARATOR;
29 29
     }
30 30
     $this->setRouteRegexData($routeRegexes, $routesData, $i);
31 31
     $routeRegexes[$routesData[$i][self::VERB]] .= $routesData[$i][self::URI];
32
-    foreach($routeRegexes as $verb => $regex) {
32
+    foreach ($routeRegexes as $verb => $regex) {
33 33
       $routeRegexes[$verb] .= self::REGEX_AFFIX;   
34 34
     }
35 35
 
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
    * @throws \Exception If $file is missing or empty
44 44
    */
45 45
   private function getRoutesData($file) {
46
-    if(file_exists($file) === false) {
46
+    if (file_exists($file) === false) {
47 47
       throw new \Exception('Route file not found.');
48 48
     }
49 49
     $routesData = require $file;
50
-    if(empty($routesData)) {
50
+    if (empty($routesData)) {
51 51
       throw new \Exception('Route file is empty.');
52 52
     }
53 53
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
    * @param int $index
63 63
    */
64 64
   private function setRouteRegexData(&$routeRegexes, &$routesData, $index) {
65
-     if(isset($routeRegexes[$routesData[$index][self::VERB]]) === false) {
65
+     if (isset($routeRegexes[$routesData[$index][self::VERB]]) === false) {
66 66
         $routeRegexes[$routesData[$index][self::VERB]] = self::REGEX_PREFIX;
67 67
       }
68 68
   }
Please login to merge, or discard this patch.
src/Cacher/File.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
   {
14 14
     file_put_contents(
15 15
       $key,
16
-      '<?php return ' . var_export($value, true) . ';'
16
+      '<?php return '.var_export($value, true).';'
17 17
     );
18 18
   }
19 19
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
    */
24 24
   public function get($key)
25 25
   {
26
-    if(file_exists($key) === false) {
26
+    if (file_exists($key) === false) {
27 27
 
28 28
       return false;
29 29
     }
Please login to merge, or discard this patch.
examples/StaticRegexRoute/route.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 $route = [];
3
-for($i=0;$i<999;++$i)
3
+for ($i = 0; $i < 999; ++$i)
4 4
 {
5 5
   $route[] = ['GET', '/'.$i];
6 6
 }
Please login to merge, or discard this patch.
examples/StaticRegexRoute/index-cache.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-require __DIR__ . '/../../vendor/autoload.php';
2
+require __DIR__.'/../../vendor/autoload.php';
3 3
 $applicationRouter = new Skansing\Escapology\Router\Application(
4 4
   new RegexDispatcher($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']),
5 5
   null,
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 $routeFound = $applicationRouter->handle(
10 10
   __DIR__.'/route.php'
11 11
 );
12
-if($routeFound) {
12
+if ($routeFound) {
13 13
   require __DIR__.'/newApplication/index.php';
14 14
 } else {
15 15
   require __DIR__.'/oldApplication/index.php';
Please login to merge, or discard this patch.
examples/StaticRegexRoute/index.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-require __DIR__ . '/../../vendor/autoload.php';
2
+require __DIR__.'/../../vendor/autoload.php';
3 3
 $applicationRouter = new Skansing\Escapology\Router\Application(
4 4
   new RegexDispatcher($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']),
5 5
   null,
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 $routeFound = $applicationRouter->handle(
10 10
   __DIR__.'/route.php'
11 11
 );
12
-if($routeFound) {
12
+if ($routeFound) {
13 13
   require __DIR__.'/newApplication/index.php';
14 14
 } else {
15 15
   require __DIR__.'/oldApplication/index.php';
Please login to merge, or discard this patch.