Completed
Push — master ( 0b0c1f...220ceb )
by Sinnarasa
02:14
created
src/Routing/Dispatcher/MvcDispatcher.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         foreach ($reflectionMethod->getParameters() as $arg) {
38 38
             if (!is_null($arg->getClass())) {
39 39
                 $class = $arg->getClass()->name;
40
-                array_unshift($dependencies, call_user_func_array($this->route->getTarget('di'),[$class]));
40
+                array_unshift($dependencies, call_user_func_array($this->route->getTarget('di'), [$class]));
41 41
             }
42 42
         }
43 43
         if ($this->route->getResponse('code') == 202)
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
         $constructor = $reflector->getConstructor();
59 59
         if (is_null($constructor)) {
60 60
             $class = $this->route->getTarget('controller');
61
-            return call_user_func_array($this->route->getTarget('di'),[$class]);
61
+            return call_user_func_array($this->route->getTarget('di'), [$class]);
62 62
         }
63 63
         $dependencies = $constructor->getParameters();
64 64
         $arguments = [];
65 65
         foreach ($dependencies as $dep) {
66 66
             $class = $dep->getClass()->name;
67
-            array_push($arguments, call_user_func_array($this->route->getTarget('di'),[$class]));
67
+            array_push($arguments, call_user_func_array($this->route->getTarget('di'), [$class]));
68 68
         }
69 69
         return $reflector->newInstanceArgs($arguments);
70 70
     }
Please login to merge, or discard this patch.
src/Routing/Match/RoutesMatch.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     private function generateTarget()
88 88
     {
89
-        if(is_callable($this->request['path'])){
89
+        if (is_callable($this->request['path'])) {
90 90
             $this->router->route->setCallback($this->request['path']);
91 91
             $this->router->route->setDetail($this->request);
92 92
             $this->anonymous();
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
                     ? $this->router->route->setCallback($this->request['path']['use'])
100 100
                     : $this->router->route->setCallback($this->request['path']);
101 101
             $this->router->route->setDetail($this->request);
102
-            if($this->validMethod()) {
103
-                $this->anonymous();$this->mvc();$this->template();
102
+            if ($this->validMethod()) {
103
+                $this->anonymous(); $this->mvc(); $this->template();
104 104
                 $this->router->route->setResponse(['code' => 202, 'message' => 'Accepted']);
105
-            }else
105
+            } else
106 106
                 $this->router->route->setResponse(['code' => 405, 'message' => 'Method Not Allowed']);
107 107
         }
108 108
         return $this->router->route->hasTarget();
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             $index = isset($this->request['index']) ? $this->request['index'] : 0;
145 145
             $class = (class_exists($routes[0]))
146 146
                 ? $routes[0]
147
-                : $this->router->collection->getRoutes()['namespace_'.$index].$routes[0];
147
+                : $this->router->collection->getRoutes()['namespace_' . $index] . $routes[0];
148 148
             if (!class_exists($class))
149 149
                 throw new \Exception('Class "' . $class . '." is not found');
150 150
             if (method_exists($class, $routes[1])) {
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
             $extension = explode('.', $path);
173 173
             $extension = end($extension);
174 174
             $index = isset($this->request['index']) ? $this->request['index'] : 0;
175
-            $block = $this->router->collection->getRoutes('path_'.$index);
175
+            $block = $this->router->collection->getRoutes('path_' . $index);
176 176
             if (in_array('.' . $extension, $this->router->getConfig()['viewExtension'])) {
177 177
                 if (is_file($block . $path)) {
178 178
                     $target = $block . $path;
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
                 throw new \Exception('Template file "' . $path . '" is not found in "' . $block . '"');
189 189
             } else {
190 190
                 foreach ($this->router->getConfig()['viewExtension'] as $ext) {
191
-                    if (is_file($block . $path . $ext)){
191
+                    if (is_file($block . $path . $ext)) {
192 192
                         $target = $block . $path . $ext;
193
-                        $this->router->route->setTarget(['dispatcher' => 'JetFire\Routing\Dispatcher\TemplateDispatcher', 'template' => $target,'block' => $block,  'extension' => str_replace('.', '', $ext),'callback' => $this->router->getConfig()['viewCallback']]);
193
+                        $this->router->route->setTarget(['dispatcher' => 'JetFire\Routing\Dispatcher\TemplateDispatcher', 'template' => $target, 'block' => $block, 'extension' => str_replace('.', '', $ext), 'callback' => $this->router->getConfig()['viewCallback']]);
194 194
                         return true;
195 195
                     }
196 196
                 }
197
-                throw new \Exception('Template file "' . $path . '" is not found in "' .$block . '"');
197
+                throw new \Exception('Template file "' . $path . '" is not found in "' . $block . '"');
198 198
             }
199 199
         }
200 200
         return false;
Please login to merge, or discard this patch.
src/Routing/Match/SmartMatch.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
     {
44 44
         foreach ($this->router->getConfig()['viewExtension'] as $extension) {
45 45
             for ($i = 0; $i < $this->router->collection->countRoutes; ++$i) {
46
-                $url = explode('/', str_replace($this->router->collection->getRoutes('prefix_' . $i), '',$this->router->route->getUrl()));
46
+                $url = explode('/', str_replace($this->router->collection->getRoutes('prefix_' . $i), '', $this->router->route->getUrl()));
47 47
                 $end = array_pop($url);
48
-                $url = implode('/', array_map('ucwords', $url)).'/'.$end;
48
+                $url = implode('/', array_map('ucwords', $url)) . '/' . $end;
49 49
                 if (is_file(($template = rtrim($this->router->collection->getRoutes('path_' . $i), '/') . $url . $extension))) {
50 50
                     $this->router->route->setTarget([
51 51
                         'dispatcher' => 'JetFire\Routing\Dispatcher\TemplateDispatcher',
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
     {
69 69
         $routes = array_slice(explode('/', $this->router->route->getUrl()), 1);
70 70
         $i = 0;
71
-        do{
72
-            $route =  ('/' . $routes[0] == $this->router->collection->getRoutes('prefix_' . $i))
71
+        do {
72
+            $route = ('/' . $routes[0] == $this->router->collection->getRoutes('prefix_' . $i))
73 73
                 ? array_slice($routes, 1) : $routes;
74 74
             if (isset($route[0])) {
75
-                $class =  (class_exists($this->router->collection->getRoutes('namespace_' . $i). ucfirst($route[0]) . 'Controller'))
76
-                    ? $this->router->collection->getRoutes('namespace_' . $i). ucfirst($route[0]) . 'Controller'
75
+                $class = (class_exists($this->router->collection->getRoutes('namespace_' . $i) . ucfirst($route[0]) . 'Controller'))
76
+                    ? $this->router->collection->getRoutes('namespace_' . $i) . ucfirst($route[0]) . 'Controller'
77 77
                     : ucfirst($route[0]) . 'Controller';
78 78
                 if (isset($route[1]) && method_exists($class, $route[1])) {
79 79
                     $this->router->route->setTarget([
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
                 }
88 88
             }
89 89
             ++$i;
90
-        }while($i < $this->router->collection->countRoutes);
90
+        }while ($i < $this->router->collection->countRoutes);
91 91
         return false;
92 92
     }
93 93
 
Please login to merge, or discard this patch.
src/Routing/Route.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -207,8 +207,8 @@
 block discarded – undo
207 207
     /**
208 208
      * @return array
209 209
      */
210
-    public function getData(){
211
-        return (isset($this->getDetail()['data']) && is_array($this->getDetail()['data']))?$this->getDetail()['data']:[];
210
+    public function getData() {
211
+        return (isset($this->getDetail()['data']) && is_array($this->getDetail()['data'])) ? $this->getDetail()['data'] : [];
212 212
     }
213 213
 
214 214
     /**
Please login to merge, or discard this patch.
src/Routing/RouteCollection.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function addRoutes($routes = null, $options = [])
44 44
     {
45
-        if(!is_null($routes) && !is_array($routes)) {
45
+        if (!is_null($routes) && !is_array($routes)) {
46 46
             if (strpos($routes, '.php') === false) $routes = trim($routes, '/') . '/';
47 47
             if (is_file($routes . '/routes.php') && is_array($routesFile = include $routes . '/routes.php')) $routes = $routesFile;
48 48
             elseif (is_file($routes) && is_array($routesFile = include $routes)) $routes = $routesFile;
49
-            else throw new \InvalidArgumentException('Argument for "' . get_called_class() . '" constructor is not recognized. Expected argument array or file containing array but "'.$routes.'" given');
49
+            else throw new \InvalidArgumentException('Argument for "' . get_called_class() . '" constructor is not recognized. Expected argument array or file containing array but "' . $routes . '" given');
50 50
         }
51 51
         $this->routes['routes_' . $this->countRoutes] = is_array($routes) ? $routes : [];
52 52
         $this->routes['path_' . $this->countRoutes] = (isset($options['path']) && !empty($options['path'])) ? rtrim($options['path'], '/') . '/' : '';
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function getRoutes($key = null)
63 63
     {
64
-        if(!is_null($key))
65
-            return isset($this->routes[$key])?$this->routes[$key]:'';
64
+        if (!is_null($key))
65
+            return isset($this->routes[$key]) ? $this->routes[$key] : '';
66 66
         return $this->routes;
67 67
     }
68 68
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         } elseif (is_string($args))
79 79
             for ($i = 0; $i < $this->countRoutes; ++$i)
80 80
                 $this->routes['prefix_' . $i] = '/' . trim($args, '/');
81
-        if($this->countRoutes == 0)$this->countRoutes++;
81
+        if ($this->countRoutes == 0)$this->countRoutes++;
82 82
     }
83 83
 
84 84
     /**
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
     {
89 89
         $nbrArgs = count($args);
90 90
         for ($i = 0; $i < $nbrArgs; ++$i) {
91
-            if(is_array($args[$i])){
91
+            if (is_array($args[$i])) {
92 92
                 $this->routes['path_' . $i] = (isset($args[$i]['path']) && !empty($args[$i]['path'])) ? rtrim($args[$i]['path'], '/') . '/' : '';
93 93
                 $this->routes['namespace_' . $i] = (isset($args[$i]['namespace']) && !empty($args[$i]['namespace'])) ? trim($args[$i]['namespace'], '\\') . '\\' : '';
94
-                $this->routes['prefix_' . $i] = (isset($args[$i]['prefix']) && !empty($args[$i]['prefix'])) ? '/'.trim($args[$i]['prefix'], '/') : '';
95
-                if(!isset($this->routes['routes_' . $i]))$this->routes['routes_' . $i] = [];
94
+                $this->routes['prefix_' . $i] = (isset($args[$i]['prefix']) && !empty($args[$i]['prefix'])) ? '/' . trim($args[$i]['prefix'], '/') : '';
95
+                if (!isset($this->routes['routes_' . $i]))$this->routes['routes_' . $i] = [];
96 96
             }
97 97
         }
98
-        if($this->countRoutes == 0)$this->countRoutes++;
98
+        if ($this->countRoutes == 0)$this->countRoutes++;
99 99
     }
100 100
 
101 101
     /**
Please login to merge, or discard this patch.
src/Routing/Router.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
     {
45 45
         $this->collection = $collection;
46 46
         $this->route = new Route();
47
-        $this->config['di'] = function($class){
47
+        $this->config['di'] = function($class) {
48 48
             return new $class;
49 49
         };
50 50
     }
Please login to merge, or discard this patch.