@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | public function getServiceName() { |
83 | 83 | |
84 | - return (empty($this->service))?"default":implode('.', $this->service); |
|
84 | + return (empty($this->service)) ? "default" : implode('.', $this->service); |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | public function getParameter($key) { |
105 | 105 | |
106 | - return (isset($this->parameters[$key]))?$this->parameters[$key]:null; |
|
106 | + return (isset($this->parameters[$key])) ? $this->parameters[$key] : null; |
|
107 | 107 | |
108 | 108 | } |
109 | 109 | |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | |
143 | 143 | public function isQueryRequired($key) { |
144 | 144 | |
145 | - return isset($this->query[$key])?$this->query[$key]["required"]:false; |
|
145 | + return isset($this->query[$key]) ? $this->query[$key]["required"] : false; |
|
146 | 146 | |
147 | 147 | } |
148 | 148 | |
149 | 149 | public function getQueryRegex($key) { |
150 | 150 | |
151 | - return isset($this->query[$key])?$this->query[$key]["regex"]:null; |
|
151 | + return isset($this->query[$key]) ? $this->query[$key]["regex"] : null; |
|
152 | 152 | |
153 | 153 | } |
154 | 154 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | /* if it's available a bit associated with the parameter name, it is compared against |
221 | 221 | * it's regular expression in order to extrect backreferences |
222 | 222 | */ |
223 | - if (preg_match('/^' . $value['regex'] . '$/', $path[$key], $matches)) { |
|
223 | + if (preg_match('/^'.$value['regex'].'$/', $path[$key], $matches)) { |
|
224 | 224 | |
225 | 225 | if (count($matches) == 1) $matches = $matches[0]; // This is the case where no backreferences are present or available. |
226 | 226 |
@@ -113,8 +113,9 @@ discard block |
||
113 | 113 | $this->extra |
114 | 114 | ); |
115 | 115 | |
116 | + } else { |
|
117 | + return null; |
|
116 | 118 | } |
117 | - else return null; |
|
118 | 119 | |
119 | 120 | } |
120 | 121 | |
@@ -294,7 +295,10 @@ discard block |
||
294 | 295 | */ |
295 | 296 | if (preg_match('/^' . $value['regex'] . '$/', $bits[$key], $matches)) { |
296 | 297 | |
297 | - if (count($matches) == 1) $matches = $matches[0]; // This is the case where no backreferences are present or available. |
|
298 | + if (count($matches) == 1) { |
|
299 | + $matches = $matches[0]; |
|
300 | + } |
|
301 | + // This is the case where no backreferences are present or available. |
|
298 | 302 | |
299 | 303 | // The extracted value (with any backreference available) is added to the query parameters. |
300 | 304 | $this->request->query()->set($key, $matches); |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | |
151 | 151 | public function load($routes) { |
152 | 152 | |
153 | - if ( !empty($routes) ) { |
|
153 | + if (!empty($routes)) { |
|
154 | 154 | |
155 | - foreach( $routes as $name => $route ) { |
|
155 | + foreach ($routes as $name => $route) { |
|
156 | 156 | |
157 | 157 | $this->add($route['route'], $route['type'], $route['class'], $route['parameters']); |
158 | 158 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | $routes = array(); |
192 | 192 | |
193 | - foreach($this->routes as $name => $route) { |
|
193 | + foreach ($this->routes as $name => $route) { |
|
194 | 194 | |
195 | 195 | $routes[$name] = $route->getData(); |
196 | 196 | |
@@ -213,14 +213,14 @@ discard block |
||
213 | 213 | ->setClassName($class) // Class to be invoked |
214 | 214 | ->setParameters($parameters); // Parameters passed via the composer.json configuration (cache, ttl, etc...) |
215 | 215 | |
216 | - $this->logger->debug("ROUTE: " . implode("/", $folders)); |
|
216 | + $this->logger->debug("ROUTE: ".implode("/", $folders)); |
|
217 | 217 | |
218 | 218 | //$this->logger->debug("PARAMETERS: " . var_export($value, true)); |
219 | 219 | |
220 | 220 | // This method generate a global regular expression which will be able to match all the URI supported by the route |
221 | 221 | $regex = $this->parser->read($folders, $route); |
222 | 222 | |
223 | - $this->logger->debug("ROUTE: " . $regex); |
|
223 | + $this->logger->debug("ROUTE: ".$regex); |
|
224 | 224 | |
225 | 225 | //$this->logger->debug("PARAMETERS: " . var_export($value, true)); |
226 | 226 |
@@ -103,7 +103,9 @@ |
||
103 | 103 | */ |
104 | 104 | $param_regex .= $this->param($key, $string, $value); |
105 | 105 | |
106 | - if ($value->isQueryRequired($key)) $param_required = true; |
|
106 | + if ($value->isQueryRequired($key)) { |
|
107 | + $param_required = true; |
|
108 | + } |
|
107 | 109 | |
108 | 110 | $this->logger->debug("PARAMETER REGEX: " . $param_regex); |
109 | 111 |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | |
93 | 93 | $methods = $this->configuration->get('allowed-http-methods'); |
94 | 94 | |
95 | - if ( ( $methods != null || !empty($methods) ) && in_array($method, $methods) === false ) { |
|
95 | + if (($methods != null || !empty($methods)) && in_array($method, $methods) === false) { |
|
96 | 96 | |
97 | 97 | throw new DispatcherException("Method not allowed", 0, null, 405, array( |
98 | - "Allow" => implode(",",$methods) |
|
98 | + "Allow" => implode(",", $methods) |
|
99 | 99 | )); |
100 | 100 | |
101 | 101 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | $methods = $service->getImplementedMethods(); |
138 | 138 | |
139 | - if ( in_array($method, $methods) ) { |
|
139 | + if (in_array($method, $methods)) { |
|
140 | 140 | |
141 | 141 | $callable = $service->getMethod($method); |
142 | 142 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | foreach ($this->table->routes() as $regex => $value) { |
180 | 180 | |
181 | 181 | // The current uri is checked against all the global regular expressions associated with the routes |
182 | - if (preg_match("/" . $regex . "/", $path, $matches)) { |
|
182 | + if (preg_match("/".$regex."/", $path, $matches)) { |
|
183 | 183 | |
184 | 184 | /* If a route is matched, all the bits of the route string are evalued in order to create |
185 | 185 | * new query parameters which will be available for the service class |
@@ -104,7 +104,9 @@ |
||
104 | 104 | |
105 | 105 | if (!$this->bypass) { |
106 | 106 | |
107 | - if (!$this->parse()) throw new DispatcherException("Unable to find a valid route for the specified uri", 0, null, 404); |
|
107 | + if (!$this->parse()) { |
|
108 | + throw new DispatcherException("Unable to find a valid route for the specified uri", 0, null, 404); |
|
109 | + } |
|
108 | 110 | |
109 | 111 | } |
110 | 112 |