Completed
Push — master ( 93721c...427d4b )
by Sinnarasa
04:49
created
src/Routing/Router.php 1 patch
Braces   +17 added lines, -10 removed lines patch added patch discarded remove patch
@@ -86,7 +86,9 @@  discard block
 block discarded – undo
86 86
     public function run()
87 87
     {
88 88
         $this->setUrl();
89
-        if ($this->config['generateRoutesPath']) $this->collection->generateRoutesPath();
89
+        if ($this->config['generateRoutesPath']) {
90
+            $this->collection->generateRoutesPath();
91
+        }
90 92
         if ($this->match()) {
91 93
             $this->handle();
92 94
             $this->callTarget();
@@ -99,8 +101,9 @@  discard block
 block discarded – undo
99 101
      */
100 102
     public function setUrl($url = null)
101 103
     {
102
-        if (is_null($url))
103
-            $url = (isset($_GET['url'])) ? $_GET['url'] : substr(str_replace(str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']), '', $_SERVER['REQUEST_URI']), 1);
104
+        if (is_null($url)) {
105
+                    $url = (isset($_GET['url'])) ? $_GET['url'] : substr(str_replace(str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']), '', $_SERVER['REQUEST_URI']), 1);
106
+        }
104 107
         $this->route->setUrl('/' . trim(explode('?', $url)[0], '/'));
105 108
     }
106 109
 
@@ -111,8 +114,9 @@  discard block
 block discarded – undo
111 114
     {
112 115
         foreach ($this->config['matcher'] as $matcher) {
113 116
             $this->config['matcherInstance'][$matcher] = new $matcher($this);
114
-            if (call_user_func([$this->config['matcherInstance'][$matcher], 'match']))
115
-                return true;
117
+            if (call_user_func([$this->config['matcherInstance'][$matcher], 'match'])) {
118
+                            return true;
119
+            }
116 120
         }
117 121
         return false;
118 122
     }
@@ -157,12 +161,15 @@  discard block
 block discarded – undo
157 161
     {
158 162
         if (isset($this->route->getDetail()['response_templates']) && isset($this->route->getDetail()['response_templates'][$code = $this->response->getStatusCode()])) {
159 163
             $this->route->setCallback($this->route->getDetail()['response_templates'][$code]);
160
-            if(!isset($this->config['matcherInstance']))
161
-                foreach ($this->config['matcher'] as $matcher)
162
-                    $this->config['matcherInstance'][$matcher] = new $matcher($this);
164
+            if(!isset($this->config['matcherInstance'])) {
165
+                            foreach ($this->config['matcher'] as $matcher)
166
+                    $this->config['matcherInstance'][$matcher] = new $matcher($this);
167
+            }
163 168
             foreach($this->config['matcherInstance'] as $instance) {
164
-                foreach (call_user_func([$instance, 'getMatcher']) as $match)
165
-                    if (call_user_func([$instance, $match])){ $this->callTarget(); break; }
169
+                foreach (call_user_func([$instance, 'getMatcher']) as $match) {
170
+                                    if (call_user_func([$instance, $match])){ $this->callTarget();
171
+                }
172
+                break; }
166 173
             }
167 174
             $this->response->setStatusCode($code);
168 175
         }
Please login to merge, or discard this patch.