@@ -76,8 +76,9 @@ |
||
| 76 | 76 | public function resources(array $controllers) |
| 77 | 77 | { |
| 78 | 78 | $resource = new Resource; |
| 79 | - foreach ($controllers as $controller) |
|
| 80 | - $resource->set($this->resource($controller)); |
|
| 79 | + foreach ($controllers as $controller) { |
|
| 80 | + $resource->set($this->resource($controller)); |
|
| 81 | + } |
|
| 81 | 82 | return $resource; |
| 82 | 83 | } |
| 83 | 84 | |
@@ -173,7 +173,9 @@ |
||
| 173 | 173 | foreach ($segments as $index => $segment) { |
| 174 | 174 | if (strpos($segment, "{") === 0) { |
| 175 | 175 | $pattern .= "/{" . $segments[$index - 1] . "_" . ltrim($segment, "{"); |
| 176 | - } else $pattern .= $segment; |
|
| 176 | + } else { |
|
| 177 | + $pattern .= $segment; |
|
| 178 | + } |
|
| 177 | 179 | } |
| 178 | 180 | |
| 179 | 181 | return $pattern; |
@@ -41,7 +41,9 @@ |
||
| 41 | 41 | { |
| 42 | 42 | if ($route->hasMetadata($this->metadataStrategyKey)) { |
| 43 | 43 | $route->setStrategy($route->getMetadata($this->metadataStrategyKey)); |
| 44 | - } else $route->setStrategy(null); |
|
| 44 | + } else { |
|
| 45 | + $route->setStrategy(null); |
|
| 46 | + } |
|
| 45 | 47 | |
| 46 | 48 | $this->enhance($route); |
| 47 | 49 | |
@@ -117,7 +117,9 @@ discard block |
||
| 117 | 117 | if (strpos($pattern, "{") !== false) { |
| 118 | 118 | $index = $this->getDynamicIndex($method, $pattern); |
| 119 | 119 | $this->dynamics[$index][$pattern] = $route; |
| 120 | - } else $this->statics[$method][$pattern] = $route; |
|
| 120 | + } else { |
|
| 121 | + $this->statics[$method][$pattern] = $route; |
|
| 122 | + } |
|
| 121 | 123 | } |
| 122 | 124 | |
| 123 | 125 | return $group; |
@@ -142,8 +144,9 @@ discard block |
||
| 142 | 144 | public function match(array $methods, $pattern, $action) |
| 143 | 145 | { |
| 144 | 146 | $group = new Group; |
| 145 | - foreach ($methods as $method) |
|
| 146 | - $group->set($this->set($method, $pattern, $action)); |
|
| 147 | + foreach ($methods as $method) { |
|
| 148 | + $group->set($this->set($method, $pattern, $action)); |
|
| 149 | + } |
|
| 147 | 150 | return $group; |
| 148 | 151 | } |
| 149 | 152 | |
@@ -186,8 +189,9 @@ discard block |
||
| 186 | 189 | public function group(array $routes) |
| 187 | 190 | { |
| 188 | 191 | $group = new Group; |
| 189 | - foreach ($routes as $route) |
|
| 190 | - $group->set($route); |
|
| 192 | + foreach ($routes as $route) { |
|
| 193 | + $group->set($route); |
|
| 194 | + } |
|
| 191 | 195 | return $group; |
| 192 | 196 | } |
| 193 | 197 | |
@@ -202,7 +206,9 @@ discard block |
||
| 202 | 206 | { |
| 203 | 207 | if (strpos($pattern, "{") === false) { |
| 204 | 208 | unset($this->statics[$method][$pattern]); |
| 205 | - } else unset($this->dynamics[$this->getDynamicIndex($method, $pattern)][$pattern]); |
|
| 209 | + } else { |
|
| 210 | + unset($this->dynamics[$this->getDynamicIndex($method, $pattern)][$pattern]); |
|
| 211 | + } |
|
| 206 | 212 | } |
| 207 | 213 | |
| 208 | 214 | /** |
@@ -257,7 +263,9 @@ discard block |
||
| 257 | 263 | if ($closingNumber !== count($segments) - 1) { |
| 258 | 264 | if (preg_match("~" . self::DYNAMIC_REGEX . "(*SKIP)(*F)|\]~x", $withoutClosing)) { |
| 259 | 265 | throw new BadRouteException(BadRouteException::OPTIONAL_SEGMENTS_ON_MIDDLE); |
| 260 | - } else throw new BadRouteException(BadRouteException::UNCLOSED_OPTIONAL_SEGMENTS); |
|
| 266 | + } else { |
|
| 267 | + throw new BadRouteException(BadRouteException::UNCLOSED_OPTIONAL_SEGMENTS); |
|
| 268 | + } |
|
| 261 | 269 | } |
| 262 | 270 | } |
| 263 | 271 | |
@@ -296,8 +304,9 @@ discard block |
||
| 296 | 304 | public function findStaticRoute($method, $pattern) |
| 297 | 305 | { |
| 298 | 306 | $method = strtolower($method); |
| 299 | - if (isset($this->statics[$method]) && isset($this->statics[$method][$pattern])) |
|
| 300 | - return $this->statics[$method][$pattern]; |
|
| 307 | + if (isset($this->statics[$method]) && isset($this->statics[$method][$pattern])) { |
|
| 308 | + return $this->statics[$method][$pattern]; |
|
| 309 | + } |
|
| 301 | 310 | return false; |
| 302 | 311 | } |
| 303 | 312 | |
@@ -333,8 +342,9 @@ discard block |
||
| 333 | 342 | public function getWildcards() |
| 334 | 343 | { |
| 335 | 344 | $wildcards = []; |
| 336 | - foreach ($this->wildcards as $token => $regex) |
|
| 337 | - $wildcards[substr($token, 1)] = substr($regex, 1); |
|
| 345 | + foreach ($this->wildcards as $token => $regex) { |
|
| 346 | + $wildcards[substr($token, 1)] = substr($regex, 1); |
|
| 347 | + } |
|
| 338 | 348 | return $wildcards; |
| 339 | 349 | } |
| 340 | 350 | |
@@ -69,8 +69,9 @@ discard block |
||
| 69 | 69 | public function controllers(array $controllers) |
| 70 | 70 | { |
| 71 | 71 | $group = new Group; |
| 72 | - foreach ($controllers as $controller) |
|
| 73 | - $group->set($this->controller($controller)); |
|
| 72 | + foreach ($controllers as $controller) { |
|
| 73 | + $group->set($this->controller($controller)); |
|
| 74 | + } |
|
| 74 | 75 | return $group; |
| 75 | 76 | } |
| 76 | 77 | |
@@ -100,8 +101,9 @@ discard block |
||
| 100 | 101 | public function controllersWithoutPrefix(array $controllers) |
| 101 | 102 | { |
| 102 | 103 | $group = new Group; |
| 103 | - foreach ($controllers as $controller) |
|
| 104 | - $group->set($this->controllerWithoutPrefix($controller)); |
|
| 104 | + foreach ($controllers as $controller) { |
|
| 105 | + $group->set($this->controllerWithoutPrefix($controller)); |
|
| 106 | + } |
|
| 105 | 107 | return $group; |
| 106 | 108 | } |
| 107 | 109 | |
@@ -134,7 +136,9 @@ discard block |
||
| 134 | 136 | |
| 135 | 137 | if ($strategy !== null) { |
| 136 | 138 | $route->setStrategy($strategy); |
| 137 | - } else $route->setStrategy($controllerDefaultStrategy); |
|
| 139 | + } else { |
|
| 140 | + $route->setStrategy($controllerDefaultStrategy); |
|
| 141 | + } |
|
| 138 | 142 | |
| 139 | 143 | $group->set($route); |
| 140 | 144 | } |
@@ -37,9 +37,12 @@ discard block |
||
| 37 | 37 | public function set($route) |
| 38 | 38 | { |
| 39 | 39 | if ($route instanceof Group) { |
| 40 | - foreach ($route->all() as $r) |
|
| 41 | - $this->routes[] = $r; |
|
| 42 | - } else $this->routes[] = $route; |
|
| 40 | + foreach ($route->all() as $r) { |
|
| 41 | + $this->routes[] = $r; |
|
| 42 | + } |
|
| 43 | + } else { |
|
| 44 | + $this->routes[] = $route; |
|
| 45 | + } |
|
| 43 | 46 | return $this; |
| 44 | 47 | } |
| 45 | 48 | |
@@ -88,8 +91,9 @@ discard block |
||
| 88 | 91 | |
| 89 | 92 | public function forget() |
| 90 | 93 | { |
| 91 | - foreach ($this->routes as $route) |
|
| 92 | - $route->forget(); |
|
| 94 | + foreach ($this->routes as $route) { |
|
| 95 | + $route->forget(); |
|
| 96 | + } |
|
| 93 | 97 | return $this; |
| 94 | 98 | } |
| 95 | 99 | |
@@ -102,8 +106,9 @@ discard block |
||
| 102 | 106 | |
| 103 | 107 | public function setMethod($method) |
| 104 | 108 | { |
| 105 | - foreach ($this->routes as $route) |
|
| 106 | - $route->setMethod($method); |
|
| 109 | + foreach ($this->routes as $route) { |
|
| 110 | + $route->setMethod($method); |
|
| 111 | + } |
|
| 107 | 112 | return $this; |
| 108 | 113 | } |
| 109 | 114 | |
@@ -116,8 +121,9 @@ discard block |
||
| 116 | 121 | |
| 117 | 122 | public function setAction($action) |
| 118 | 123 | { |
| 119 | - foreach ($this->routes as $route) |
|
| 120 | - $route->setAction($action); |
|
| 124 | + foreach ($this->routes as $route) { |
|
| 125 | + $route->setAction($action); |
|
| 126 | + } |
|
| 121 | 127 | return $this; |
| 122 | 128 | } |
| 123 | 129 | |
@@ -130,8 +136,9 @@ discard block |
||
| 130 | 136 | |
| 131 | 137 | public function setNamespace($namespace) |
| 132 | 138 | { |
| 133 | - foreach ($this->routes as $route) |
|
| 134 | - $route->setNamespace($namespace); |
|
| 139 | + foreach ($this->routes as $route) { |
|
| 140 | + $route->setNamespace($namespace); |
|
| 141 | + } |
|
| 135 | 142 | return $this; |
| 136 | 143 | } |
| 137 | 144 | |
@@ -145,8 +152,9 @@ discard block |
||
| 145 | 152 | public function setPrefix($prefix) |
| 146 | 153 | { |
| 147 | 154 | $prefix = "/" . ltrim($prefix, "/"); |
| 148 | - foreach ($this->routes as $route) |
|
| 149 | - $route->setPattern(rtrim($prefix . $route->getPattern(), "/")); |
|
| 155 | + foreach ($this->routes as $route) { |
|
| 156 | + $route->setPattern(rtrim($prefix . $route->getPattern(), "/")); |
|
| 157 | + } |
|
| 150 | 158 | return $this; |
| 151 | 159 | } |
| 152 | 160 | |
@@ -161,8 +169,9 @@ discard block |
||
| 161 | 169 | |
| 162 | 170 | public function setMetadata($key, $value) |
| 163 | 171 | { |
| 164 | - foreach ($this->routes as $route) |
|
| 165 | - $route->setMetadata($key, $value); |
|
| 172 | + foreach ($this->routes as $route) { |
|
| 173 | + $route->setMetadata($key, $value); |
|
| 174 | + } |
|
| 166 | 175 | return $this; |
| 167 | 176 | } |
| 168 | 177 | |
@@ -175,8 +184,9 @@ discard block |
||
| 175 | 184 | |
| 176 | 185 | public function setMetadataArray(array $metadata) |
| 177 | 186 | { |
| 178 | - foreach ($this->routes as $route) |
|
| 179 | - $route->setMetadataArray($metadata); |
|
| 187 | + foreach ($this->routes as $route) { |
|
| 188 | + $route->setMetadataArray($metadata); |
|
| 189 | + } |
|
| 180 | 190 | return $this; |
| 181 | 191 | } |
| 182 | 192 | |
@@ -189,8 +199,9 @@ discard block |
||
| 189 | 199 | |
| 190 | 200 | public function setDefaults(array $defaults) |
| 191 | 201 | { |
| 192 | - foreach ($this->routes as $route) |
|
| 193 | - $route->setDefaults($defaults); |
|
| 202 | + foreach ($this->routes as $route) { |
|
| 203 | + $route->setDefaults($defaults); |
|
| 204 | + } |
|
| 194 | 205 | return $this; |
| 195 | 206 | } |
| 196 | 207 | |
@@ -205,8 +216,9 @@ discard block |
||
| 205 | 216 | |
| 206 | 217 | public function setDefault($key, $value) |
| 207 | 218 | { |
| 208 | - foreach ($this->routes as $route) |
|
| 209 | - $route->setDefault($key, $value); |
|
| 219 | + foreach ($this->routes as $route) { |
|
| 220 | + $route->setDefault($key, $value); |
|
| 221 | + } |
|
| 210 | 222 | return $this; |
| 211 | 223 | } |
| 212 | 224 | |
@@ -219,8 +231,9 @@ discard block |
||
| 219 | 231 | |
| 220 | 232 | public function setStrategy($strategy) |
| 221 | 233 | { |
| 222 | - foreach ($this->routes as $route) |
|
| 223 | - $route->setStrategy($strategy); |
|
| 234 | + foreach ($this->routes as $route) { |
|
| 235 | + $route->setStrategy($strategy); |
|
| 236 | + } |
|
| 224 | 237 | return $this; |
| 225 | 238 | } |
| 226 | 239 | |
@@ -235,8 +248,9 @@ discard block |
||
| 235 | 248 | |
| 236 | 249 | public function setConstraint($name, $regex) |
| 237 | 250 | { |
| 238 | - foreach ($this->routes as $route) |
|
| 239 | - $route->setConstraint($name, $regex); |
|
| 251 | + foreach ($this->routes as $route) { |
|
| 252 | + $route->setConstraint($name, $regex); |
|
| 253 | + } |
|
| 240 | 254 | return $this; |
| 241 | 255 | } |
| 242 | 256 | |
@@ -208,7 +208,9 @@ |
||
| 208 | 208 | |
| 209 | 209 | if ($this->controllerCreationFunction === null) { |
| 210 | 210 | return new $controller; |
| 211 | - } else return call_user_func($this->controllerCreationFunction, $controller); |
|
| 211 | + } else { |
|
| 212 | + return call_user_func($this->controllerCreationFunction, $controller); |
|
| 213 | + } |
|
| 212 | 214 | } |
| 213 | 215 | |
| 214 | 216 | /** |