@@ -205,12 +205,12 @@ |
||
| 205 | 205 | |
| 206 | 206 | //Older versions of PCRE require the 'P' in (?P<named>) |
| 207 | 207 | $pattern = '(?:' |
| 208 | - . ($pre !== '' ? $pre : null) |
|
| 209 | - . '(' |
|
| 210 | - . ($param !== '' ? "?P<$param>" : null) |
|
| 211 | - . $type |
|
| 212 | - . '))' |
|
| 213 | - . ($optional !== '' ? '?' : null); |
|
| 208 | + . ($pre !== '' ? $pre : null) |
|
| 209 | + . '(' |
|
| 210 | + . ($param !== '' ? "?P<$param>" : null) |
|
| 211 | + . $type |
|
| 212 | + . '))' |
|
| 213 | + . ($optional !== '' ? '?' : null); |
|
| 214 | 214 | |
| 215 | 215 | $route = str_replace($block, $pattern, $route); |
| 216 | 216 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $this->addRoutes($routes); |
| 31 | 31 | $this->setBasePath($basePath); |
| 32 | 32 | $this->addMatchTypes($matchTypes); |
| 33 | - if(!$server) { |
|
| 33 | + if (!$server) { |
|
| 34 | 34 | $this->server = $_SERVER; |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | if (!is_array($routes) && !$routes instanceof Traversable) { |
| 62 | 62 | throw new Exception('Routes should be an array or an instance of Traversable'); |
| 63 | 63 | } |
| 64 | - if(!empty($routes)) { |
|
| 64 | + if (!empty($routes)) { |
|
| 65 | 65 | foreach ($routes as $route) { |
| 66 | 66 | call_user_func_array(array($this, 'map'), $route); |
| 67 | 67 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | return array( |
| 178 | 178 | 'target' => $handler[2], |
| 179 | - 'params' => array_filter($params, function ($k) { return !is_numeric($k); }, ARRAY_FILTER_USE_KEY), |
|
| 179 | + 'params' => array_filter($params, function($k) { return !is_numeric($k); }, ARRAY_FILTER_USE_KEY), |
|
| 180 | 180 | 'name' => $handler[3] |
| 181 | 181 | ); |
| 182 | 182 | } |
@@ -248,12 +248,12 @@ discard block |
||
| 248 | 248 | $requestMethod = strtolower($requestMethod); |
| 249 | 249 | $methods = explode('|', $method); |
| 250 | 250 | |
| 251 | - if(in_array($requestMethod, $methods)) |
|
| 251 | + if (in_array($requestMethod, $methods)) |
|
| 252 | 252 | { |
| 253 | - if($routeString == '*') return true; |
|
| 253 | + if ($routeString == '*') return true; |
|
| 254 | 254 | |
| 255 | - if(is_array($routeString) && !empty($routeString)) { |
|
| 256 | - if($routeString[0] == '@') { |
|
| 255 | + if (is_array($routeString) && !empty($routeString)) { |
|
| 256 | + if ($routeString[0] == '@') { |
|
| 257 | 257 | return preg_match('`' . substr($routeString, 1) . '`u', $requestUrl, $params); |
| 258 | 258 | } |
| 259 | 259 | $regex = $this->compileRoute($routeString, $requestUrl); |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | break; |
| 283 | 283 | } |
| 284 | 284 | if ($regex === false) { |
| 285 | - if(!$this->getRouteRegexCheck($nPointer, $jPointer, $iPointer, $routeString, $requestUrl)) { |
|
| 285 | + if (!$this->getRouteRegexCheck($nPointer, $jPointer, $iPointer, $routeString, $requestUrl)) { |
|
| 286 | 286 | continue; |
| 287 | 287 | } |
| 288 | 288 | $jPointer++; |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | { |
| 298 | 298 | $cPointer = $nPointer; |
| 299 | 299 | $regex = in_array($cPointer, array('[', '(', '.')); |
| 300 | - if (!$regex && isset($routeString[$iPointer+1])) { |
|
| 300 | + if (!$regex && isset($routeString[$iPointer + 1])) { |
|
| 301 | 301 | $nPointer = $routeString[$iPointer + 1]; |
| 302 | 302 | $regex = in_array($nPointer, array('?', '+', '*', '{')); |
| 303 | 303 | } |
@@ -309,8 +309,8 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | public function __call($method, $arguments) |
| 311 | 311 | { |
| 312 | - if(!in_array($method, array('get', 'post', 'delete', 'put', 'patch', 'update', 'all'))) { |
|
| 313 | - throw new Exception($method . ' not exist in the '. __CLASS__); |
|
| 312 | + if (!in_array($method, array('get', 'post', 'delete', 'put', 'patch', 'update', 'all'))) { |
|
| 313 | + throw new Exception($method . ' not exist in the ' . __CLASS__); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | $methods = $method == 'all' ? implode('|', $this->all) : $method; |
@@ -250,7 +250,9 @@ |
||
| 250 | 250 | |
| 251 | 251 | if(in_array($requestMethod, $methods)) |
| 252 | 252 | { |
| 253 | - if($routeString == '*') return true; |
|
| 253 | + if($routeString == '*') { |
|
| 254 | + return true; |
|
| 255 | + } |
|
| 254 | 256 | |
| 255 | 257 | if(is_array($routeString) && !empty($routeString)) { |
| 256 | 258 | if($routeString[0] == '@') { |