@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | |
161 | 161 | $methods = $this->configuration->get('allowed-http-methods'); |
162 | 162 | |
163 | - if ( ( $methods != null || !empty($methods) ) && in_array($method, $methods) === false ) { |
|
163 | + if (($methods != null || !empty($methods)) && in_array($method, $methods) === false) { |
|
164 | 164 | |
165 | 165 | throw new DispatcherException("Method not allowed", 0, null, 405, array( |
166 | - "Allow" => implode(",",$methods) |
|
166 | + "Allow" => implode(",", $methods) |
|
167 | 167 | )); |
168 | 168 | |
169 | 169 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | $methods = $service->getImplementedMethods(); |
194 | 194 | |
195 | - if ( in_array($method, $methods) ) { |
|
195 | + if (in_array($method, $methods)) { |
|
196 | 196 | |
197 | 197 | $callable = $service->getMethod($method); |
198 | 198 | |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | |
233 | 233 | $routes = Yaml::parse($yaml); |
234 | 234 | |
235 | - if ( !empty($routes) ) { |
|
235 | + if (!empty($routes)) { |
|
236 | 236 | |
237 | - foreach( $routes as $name => $route ) { |
|
237 | + foreach ($routes as $name => $route) { |
|
238 | 238 | |
239 | 239 | $this->add($route['route'], $route['type'], $route['class'], $route['parameters']); |
240 | 240 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | foreach ($this->table->routes() as $regex => $value) { |
254 | 254 | |
255 | 255 | // The current uri is checked against all the global regular expressions associated with the routes |
256 | - if (preg_match("/" . $regex . "/", $path, $matches)) { |
|
256 | + if (preg_match("/".$regex."/", $path, $matches)) { |
|
257 | 257 | |
258 | 258 | /* If a route is matched, all the bits of the route string are evalued in order to create |
259 | 259 | * new query parameters which will be available for the service class |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | $this->classname = $value['class']; |
271 | 271 | $this->type = $value['type']; |
272 | 272 | $this->service = implode('.', $value['service']); |
273 | - $this->service = empty($this->service)?"default":$this->service; |
|
273 | + $this->service = empty($this->service) ? "default" : $this->service; |
|
274 | 274 | |
275 | 275 | return true; |
276 | 276 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | |
285 | 285 | private function evalUri($parameters, $bits) { |
286 | 286 | |
287 | - $count = 0; |
|
287 | + $count = 0; |
|
288 | 288 | |
289 | 289 | // Because of the nature of the global regular expression, all the bits of the matched route are associated with a parameter key |
290 | 290 | foreach ($parameters as $key => $value) { |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | /* if it's available a bit associated with the parameter name, it is compared against |
294 | 294 | * it's regular expression in order to extrect backreferences |
295 | 295 | */ |
296 | - if (preg_match('/^' . $value['regex'] . '$/', $bits[$key], $matches)) { |
|
296 | + if (preg_match('/^'.$value['regex'].'$/', $bits[$key], $matches)) { |
|
297 | 297 | |
298 | 298 | if (count($matches) == 1) $matches = $matches[0]; // This is the case where no backreferences are present or available. |
299 | 299 |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | */ |
143 | 143 | foreach ($decoded as $key => $string) { |
144 | 144 | |
145 | - $this->logger->debug("PARAMETER KEY: " . $key); |
|
145 | + $this->logger->debug("PARAMETER KEY: ".$key); |
|
146 | 146 | |
147 | - $this->logger->debug("PARAMETER STRING: " . $string); |
|
147 | + $this->logger->debug("PARAMETER STRING: ".$string); |
|
148 | 148 | |
149 | 149 | /* The key and the regex of every paramater is passed to the 'readparam' |
150 | 150 | * method which will build an appropriate regular expression and will understand |
@@ -152,14 +152,14 @@ discard block |
||
152 | 152 | */ |
153 | 153 | $param_regex .= $this->readparam($key, $string, $param_required, $value); |
154 | 154 | |
155 | - $this->logger->debug("PARAMETER REGEX: " . $param_regex); |
|
155 | + $this->logger->debug("PARAMETER REGEX: ".$param_regex); |
|
156 | 156 | |
157 | 157 | } |
158 | 158 | // Once the parameter is analyzed, the result is passed to the next iteration |
159 | 159 | return $this->readpath( |
160 | 160 | $folders, |
161 | 161 | $value, |
162 | - $regex.'(?:\/'.$param_regex.')'. (($param_required)?'{1}':'?') |
|
162 | + $regex.'(?:\/'.$param_regex.')'.(($param_required) ? '{1}' : '?') |
|
163 | 163 | ); |
164 | 164 | |
165 | 165 | } else { |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * If the field is required, the regular expression is completed with a '{1}' (which make it compulsory), |
225 | 225 | * otherwise a '?' is added. |
226 | 226 | */ |
227 | - return '(?P<' . $key . '>' . $string . ')' . (($field_required)?'{1}':'?'); |
|
227 | + return '(?P<'.$key.'>'.$string.')'.(($field_required) ? '{1}' : '?'); |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | |
@@ -232,24 +232,24 @@ discard block |
||
232 | 232 | private function add($folders, $type, $class, $parameters) { |
233 | 233 | |
234 | 234 | // The values associated with a route are as follows: |
235 | - $value = array( |
|
236 | - "type" => $type, // Type of route |
|
237 | - "class" => $class, // Class to be invoked |
|
238 | - "service" => array(), // Service name (it can be a list of namespaces plus a final service name) |
|
235 | + $value = array( |
|
236 | + "type" => $type, // Type of route |
|
237 | + "class" => $class, // Class to be invoked |
|
238 | + "service" => array(), // Service name (it can be a list of namespaces plus a final service name) |
|
239 | 239 | "parameters" => $parameters, // Parameters passed via the composer.json configuration (cache, ttl, etc...) |
240 | 240 | "query" => array() // List of parameters with their regular expression that must be added among the query parameters |
241 | 241 | ); |
242 | 242 | |
243 | - $this->logger->debug("ROUTE: " . implode("/", $folders)); |
|
243 | + $this->logger->debug("ROUTE: ".implode("/", $folders)); |
|
244 | 244 | |
245 | - $this->logger->debug("PARAMETERS: " . var_export($value, true)); |
|
245 | + $this->logger->debug("PARAMETERS: ".var_export($value, true)); |
|
246 | 246 | |
247 | 247 | // This method generate a global regular expression which will be able to match all the URI supported by the route |
248 | 248 | $regex = $this->readpath($folders, $value); |
249 | 249 | |
250 | - $this->logger->debug("ROUTE: " . $regex); |
|
250 | + $this->logger->debug("ROUTE: ".$regex); |
|
251 | 251 | |
252 | - $this->logger->debug("PARAMETERS: " . var_export($value, true)); |
|
252 | + $this->logger->debug("PARAMETERS: ".var_export($value, true)); |
|
253 | 253 | |
254 | 254 | $this->routes[$regex] = $value; |
255 | 255 |
@@ -70,10 +70,11 @@ discard block |
||
70 | 70 | |
71 | 71 | $regex = $this->readpath($folders); |
72 | 72 | |
73 | - if (isset($this->routes[$regex])) |
|
74 | - return $this->routes[$regex]; |
|
75 | - else |
|
76 | - return null; |
|
73 | + if (isset($this->routes[$regex])) { |
|
74 | + return $this->routes[$regex]; |
|
75 | + } else { |
|
76 | + return null; |
|
77 | + } |
|
77 | 78 | |
78 | 79 | } |
79 | 80 | |
@@ -83,7 +84,9 @@ discard block |
||
83 | 84 | |
84 | 85 | $regex = $this->readpath($folders); |
85 | 86 | |
86 | - if (isset($this->routes[$regex])) unset($this->routes[$regex]); |
|
87 | + if (isset($this->routes[$regex])) { |
|
88 | + unset($this->routes[$regex]); |
|
89 | + } |
|
87 | 90 | |
88 | 91 | } |
89 | 92 | |
@@ -164,7 +167,9 @@ discard block |
||
164 | 167 | |
165 | 168 | } else { |
166 | 169 | // if the element is not a json string, I assume it's the service name |
167 | - if (!isset($value['service'])) $value['service'] = array(); |
|
170 | + if (!isset($value['service'])) { |
|
171 | + $value['service'] = array(); |
|
172 | + } |
|
168 | 173 | array_push($value['service'], $folder); |
169 | 174 | |
170 | 175 | return $this->readpath( |