Completed
Push — master ( 855079...1a7984 )
by Sinnarasa
02:36
created
src/Routing/RouteCollection.php 1 patch
Spacing   +11 added lines, -11 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
     /**
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     public function setMiddleware($middleware)
106 106
     {
107 107
         if (is_string($middleware)) $middleware = rtrim($middleware, '/');
108
-        if(is_array($middleware))
108
+        if (is_array($middleware))
109 109
             $this->middleware = $middleware;
110 110
         elseif (is_file($middleware) && is_array($mid = include $middleware))
111 111
             $this->middleware = $mid;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                 foreach ($this->routes['routes_' . $i] as $route => $dependencies) {
126 126
                     if (is_array($dependencies) && isset($dependencies['use']))
127 127
                         $use = (is_callable($dependencies['use'])) ? 'closure-' . $count : trim($dependencies['use'], '/');
128
-                    elseif(!is_array($dependencies))
128
+                    elseif (!is_array($dependencies))
129 129
                         $use = (is_callable($dependencies)) ? 'closure-' . $count : trim($dependencies, '/');
130 130
                     else
131 131
                         $use = $route;
Please login to merge, or discard this patch.