@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | // The URI should be considered literal except for keys and optional parts |
| 35 | 35 | // Escape everything preg_quote would escape except for : ( ) < > |
| 36 | - $expression = preg_replace('#'.Route::REGEX_ESCAPE.'#', '\\\\$0', $uri); |
|
| 36 | + $expression = preg_replace('#' . Route::REGEX_ESCAPE . '#', '\\\\$0', $uri); |
|
| 37 | 37 | |
| 38 | 38 | if (strpos($expression, '(') !== FALSE) |
| 39 | 39 | { |
@@ -42,14 +42,14 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // Insert default regex for keys |
| 45 | - $expression = str_replace(array('<', '>'), array('(?P<', '>'.Route::REGEX_SEGMENT.')'), $expression); |
|
| 45 | + $expression = str_replace(array('<', '>'), array('(?P<', '>' . Route::REGEX_SEGMENT . ')'), $expression); |
|
| 46 | 46 | |
| 47 | 47 | if ($regex) |
| 48 | 48 | { |
| 49 | 49 | $search = $replace = array(); |
| 50 | 50 | foreach ($regex as $key => $value) |
| 51 | 51 | { |
| 52 | - $search[] = "<$key>".Route::REGEX_SEGMENT; |
|
| 52 | + $search[] = "<$key>" . Route::REGEX_SEGMENT; |
|
| 53 | 53 | $replace[] = "<$key>$value"; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $expression = str_replace($search, $replace, $expression); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - return '#^'.$expression.'$#uD'; |
|
| 60 | + return '#^' . $expression . '$#uD'; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | return; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if ( ! empty($uri)) |
|
| 107 | + if (!empty($uri)) |
|
| 108 | 108 | { |
| 109 | 109 | $this->_uri = $uri; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if ( ! empty($regex)) |
|
| 112 | + if (!empty($regex)) |
|
| 113 | 113 | { |
| 114 | 114 | $this->_regex = $regex; |
| 115 | 115 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $uri = trim($request->uri(), '/'); |
| 148 | 148 | // $uri = $request->uri(); |
| 149 | 149 | |
| 150 | - if ( ! preg_match($this->_route_regex, $uri, $matches)) |
|
| 150 | + if (!preg_match($this->_route_regex, $uri, $matches)) |
|
| 151 | 151 | return FALSE; |
| 152 | 152 | |
| 153 | 153 | $params = array(); |
@@ -166,20 +166,20 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | foreach ($this->_defaults as $key => $value) |
| 168 | 168 | { |
| 169 | - if ( ! isset($params[$key]) OR $params[$key] === '') |
|
| 169 | + if (!isset($params[$key]) OR $params[$key] === '') |
|
| 170 | 170 | { |
| 171 | 171 | // Set default values for any key that was not matched |
| 172 | 172 | $params[$key] = $value; |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if ( ! empty($params['controller'])) |
|
| 176 | + if (!empty($params['controller'])) |
|
| 177 | 177 | { |
| 178 | 178 | // PSR-0: Replace underscores with spaces, run ucwords, then replace underscore |
| 179 | 179 | $params['controller'] = str_replace(' ', '_', ucwords(str_replace('_', ' ', $params['controller']))); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - if ( ! empty($params['directory'])) |
|
| 182 | + if (!empty($params['directory'])) |
|
| 183 | 183 | { |
| 184 | 184 | // PSR-0: Replace underscores with spaces, run ucwords, then replace underscore |
| 185 | 185 | $params['directory'] = str_replace(' ', '_', ucwords(str_replace('_', ' ', $params['directory']))); |
@@ -210,12 +210,12 @@ discard block |
||
| 210 | 210 | * @param boolean $required Whether or not parameters are required (initially) |
| 211 | 211 | * @return array Tuple of the compiled portion and whether or not it contained specified parameters |
| 212 | 212 | */ |
| 213 | - $compile = function ($portion, $required) use (&$compile, $defaults, $params) |
|
| 213 | + $compile = function($portion, $required) use (&$compile, $defaults, $params) |
|
| 214 | 214 | { |
| 215 | 215 | $missing = array(); |
| 216 | 216 | |
| 217 | - $pattern = '#(?:'.Route::REGEX_KEY.'|'.Route::REGEX_GROUP.')#'; |
|
| 218 | - $result = preg_replace_callback($pattern, function ($matches) use (&$compile, $defaults, &$missing, $params, &$required) |
|
| 217 | + $pattern = '#(?:' . Route::REGEX_KEY . '|' . Route::REGEX_GROUP . ')#'; |
|
| 218 | + $result = preg_replace_callback($pattern, function($matches) use (&$compile, $defaults, &$missing, $params, &$required) |
|
| 219 | 219 | { |
| 220 | 220 | if ($matches[0][0] === '<') |
| 221 | 221 | { |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | { |
| 227 | 227 | // This portion is required when a specified |
| 228 | 228 | // parameter does not match the default |
| 229 | - $required = ($required OR ! isset($defaults[$param]) OR $params[$param] !== $defaults[$param]); |
|
| 229 | + $required = ($required OR !isset($defaults[$param]) OR $params[$param] !== $defaults[$param]); |
|
| 230 | 230 | |
| 231 | 231 | // Add specified parameter to this result |
| 232 | 232 | return $params[$param]; |