@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | use ResponseTrait; |
49 | 49 | use ExtraTrait; |
50 | 50 | |
51 | - protected static $supported_methods = ['GET','PUT','POST','DELETE','OPTIONS','HEAD','TRACE','CONNECT','PURGE']; |
|
51 | + protected static $supported_methods = ['GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'HEAD', 'TRACE', 'CONNECT', 'PURGE']; |
|
52 | 52 | |
53 | 53 | public function __construct( |
54 | 54 | Configuration $configuration, |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | |
82 | 82 | $supported_methods = $this->getConfiguration()->get('supported-http-methods'); |
83 | 83 | |
84 | - if ( is_null($supported_methods) ) $supported_methods = self::$supported_methods; |
|
84 | + if (is_null($supported_methods)) $supported_methods = self::$supported_methods; |
|
85 | 85 | |
86 | - if ( method_exists($this, 'any') ) { |
|
86 | + if (method_exists($this, 'any')) { |
|
87 | 87 | |
88 | 88 | return $supported_methods; |
89 | 89 | |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | |
92 | 92 | $implemented_methods = []; |
93 | 93 | |
94 | - foreach ( $supported_methods as $method ) { |
|
94 | + foreach ($supported_methods as $method) { |
|
95 | 95 | |
96 | - if ( method_exists($this, strtolower($method)) ) array_push($implemented_methods, $method); |
|
96 | + if (method_exists($this, strtolower($method))) array_push($implemented_methods, $method); |
|
97 | 97 | |
98 | 98 | } |
99 | 99 | |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | |
110 | 110 | $method = strtolower($method); |
111 | 111 | |
112 | - if ( method_exists($this, $method) ) { |
|
112 | + if (method_exists($this, $method)) { |
|
113 | 113 | |
114 | 114 | return $method; |
115 | 115 | |
116 | - } else if ( method_exists($this, 'any') ) { |
|
116 | + } else if (method_exists($this, 'any')) { |
|
117 | 117 | |
118 | 118 | return 'any'; |
119 | 119 |
@@ -60,9 +60,9 @@ |
||
60 | 60 | |
61 | 61 | } |
62 | 62 | |
63 | - public function description($code=null) { |
|
63 | + public function description($code = null) { |
|
64 | 64 | |
65 | - if ( is_null($code) ) return $this->codes->getMessage($this->status_code); |
|
65 | + if (is_null($code)) return $this->codes->getMessage($this->status_code); |
|
66 | 66 | |
67 | 67 | return $this->codes->getMessage($code); |
68 | 68 |
@@ -229,7 +229,7 @@ |
||
229 | 229 | ) { |
230 | 230 | |
231 | 231 | $headers = $this->getHeaders(); |
232 | - $timestamp = (int) $this->getTime()->format('U')+$ttl; |
|
232 | + $timestamp = (int)$this->getTime()->format('U')+$ttl; |
|
233 | 233 | |
234 | 234 | if ($ttl > 0) { |
235 | 235 |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $events->emit($this->createServiceSpecializedEvents('dispatcher.route')); |
174 | 174 | $events->emit($this->createServiceSpecializedEvents('dispatcher.route.'.$route_type)); |
175 | 175 | |
176 | - if ( $route_type == 'ROUTE' ) { |
|
176 | + if ($route_type == 'ROUTE') { |
|
177 | 177 | $logger->debug("Route leads to service $route_service"); |
178 | 178 | $events->emit($this->createServiceSpecializedEvents('dispatcher.route.'.$route_service)); |
179 | 179 | } |
@@ -229,8 +229,8 @@ discard block |
||
229 | 229 | |
230 | 230 | $params = $route->getParameter('headers'); |
231 | 231 | |
232 | - if ( !empty($params) && is_array($params) ) { |
|
233 | - foreach($params as $name => $value) { |
|
232 | + if (!empty($params) && is_array($params)) { |
|
233 | + foreach ($params as $name => $value) { |
|
234 | 234 | $this->getResponse()->getHeaders()->set($name, $value); |
235 | 235 | } |
236 | 236 | } |
@@ -246,11 +246,11 @@ discard block |
||
246 | 246 | $code = $route->getRedirectCode(); |
247 | 247 | |
248 | 248 | $location = $route->getRedirectLocation(); |
249 | - $uri = empty($location) ? (string) $this->getRequest()->getUri() : $location; |
|
249 | + $uri = empty($location) ? (string)$this->getRequest()->getUri() : $location; |
|
250 | 250 | |
251 | 251 | $message = $route->getRedirectMessage(); |
252 | 252 | |
253 | - if ( $route->getRedirectType() == Route::REDIRECT_REFRESH ) { |
|
253 | + if ($route->getRedirectType() == Route::REDIRECT_REFRESH) { |
|
254 | 254 | |
255 | 255 | $output = empty($message) ? |
256 | 256 | "Please follow <a href=\"$location\">this link</a>" |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | |
263 | 263 | } else { |
264 | 264 | |
265 | - if ( !empty($code) ) { |
|
265 | + if (!empty($code)) { |
|
266 | 266 | $status->set($code); |
267 | - } else if ( $this->getRequest()->getVersion() == 'HTTP/1.1' ) { |
|
268 | - $status->set( (string) $this->getRequest()->getMethod() !== 'GET' ? 303 : 307); |
|
267 | + } else if ($this->getRequest()->getVersion() == 'HTTP/1.1') { |
|
268 | + $status->set((string)$this->getRequest()->getMethod() !== 'GET' ? 303 : 307); |
|
269 | 269 | } else { |
270 | 270 | $status->set(302); |
271 | 271 | } |
@@ -107,7 +107,7 @@ |
||
107 | 107 | |
108 | 108 | public function route(Request $request) { |
109 | 109 | |
110 | - $method = (string) $request->getMethod(); |
|
110 | + $method = (string)$request->getMethod(); |
|
111 | 111 | |
112 | 112 | $methods = $this->configuration->get('allowed-http-methods'); |
113 | 113 |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | public function setRedirectCode($code) { |
137 | 137 | |
138 | - if ( $code < 300 || $code >= 400 ) { |
|
138 | + if ($code < 300 || $code >= 400) { |
|
139 | 139 | throw new InvalidArgumentException("Invalid redirection code $code"); |
140 | 140 | } |
141 | 141 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | public function setRedirectType($type) { |
183 | 183 | |
184 | - if ( !in_array($type, [self::REDIRECT_REFRESH, self::REDIRECT_LOCATION]) ) { |
|
184 | + if (!in_array($type, [self::REDIRECT_REFRESH, self::REDIRECT_LOCATION])) { |
|
185 | 185 | throw new InvalidArgumentException("Invalid redirection type $type"); |
186 | 186 | } |
187 | 187 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | public function setErrorCode($code) { |
201 | 201 | |
202 | - if ( $code < 400 || $code >= 600 ) { |
|
202 | + if ($code < 400 || $code >= 600) { |
|
203 | 203 | throw new InvalidArgumentException("Invalid error code $code"); |
204 | 204 | } |
205 | 205 | |
@@ -359,13 +359,13 @@ discard block |
||
359 | 359 | // Because of the nature of the global regular expression, all the bits of the matched route are associated with a parameter key |
360 | 360 | foreach ($this->query as $key => $value) { |
361 | 361 | |
362 | - if ( isset($path[$key]) ) { |
|
362 | + if (isset($path[$key])) { |
|
363 | 363 | /* if it's available a bit associated with the parameter name, it is compared against |
364 | 364 | * it's regular expression in order to extrect backreferences |
365 | 365 | */ |
366 | - if ( preg_match('/^' . $value['regex'] . '$/', $path[$key], $matches) ) { |
|
366 | + if (preg_match('/^'.$value['regex'].'$/', $path[$key], $matches)) { |
|
367 | 367 | |
368 | - if ( count($matches) == 1 ) $matches = $matches[0]; // This is the case where no backreferences are present or available. |
|
368 | + if (count($matches) == 1) $matches = $matches[0]; // This is the case where no backreferences are present or available. |
|
369 | 369 | |
370 | 370 | // The extracted value (with any backreference available) is added to the query parameters. |
371 | 371 | $this->setRequestParameter($key, $matches); |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | */ |
392 | 392 | public function serialize() { |
393 | 393 | |
394 | - return serialize( (object) [ |
|
394 | + return serialize((object)[ |
|
395 | 395 | 'classname' => $this->classname, |
396 | 396 | 'type' => $this->type, |
397 | 397 | 'service' => $this->service, |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * Types of route that this table will accept |
42 | 42 | * @var array |
43 | 43 | */ |
44 | - const ALLOWED_ROUTES = [ "ROUTE", "REDIRECT", "ERROR" ]; |
|
44 | + const ALLOWED_ROUTES = ["ROUTE", "REDIRECT", "ERROR"]; |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Current repository of routes |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | |
91 | 91 | $type = strtoupper($type); |
92 | 92 | |
93 | - if ( !in_array($type, self::ALLOWED_ROUTES) ) { |
|
93 | + if (!in_array($type, self::ALLOWED_ROUTES)) { |
|
94 | 94 | |
95 | 95 | $this->getLogger()->error("Invalid route definition - unknown type $type for route $route)"); |
96 | 96 | |
97 | - } else if ( $type == 'ROUTE' && empty($class) ) { |
|
97 | + } else if ($type == 'ROUTE' && empty($class)) { |
|
98 | 98 | |
99 | 99 | $this->getLogger()->error("Invalid route definition - missing class for route $route)"); |
100 | 100 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | $routeData = $this->get($route); |
104 | 104 | |
105 | - if ( !is_null($routeData) ) { |
|
105 | + if (!is_null($routeData)) { |
|
106 | 106 | |
107 | 107 | $this->updateRoute($routeData, $type, $class, $parameters); |
108 | 108 | |
@@ -237,13 +237,13 @@ discard block |
||
237 | 237 | ->setClassName($class) |
238 | 238 | ->setParameters($parameters); |
239 | 239 | |
240 | - if ( !empty($parameters['redirect-code']) ) $route->setRedirectCode($parameters['redirect-code']); |
|
241 | - if ( !empty($parameters['redirect-location']) ) $route->setRedirectLocation($parameters['redirect-location']); |
|
242 | - if ( !empty($parameters['redirect-message']) ) $route->setRedirectLocation($parameters['redirect-message']); |
|
243 | - if ( !empty($parameters['redirect-type']) ) $route->setRedirectType($parameters['redirect-type']); |
|
240 | + if (!empty($parameters['redirect-code'])) $route->setRedirectCode($parameters['redirect-code']); |
|
241 | + if (!empty($parameters['redirect-location'])) $route->setRedirectLocation($parameters['redirect-location']); |
|
242 | + if (!empty($parameters['redirect-message'])) $route->setRedirectLocation($parameters['redirect-message']); |
|
243 | + if (!empty($parameters['redirect-type'])) $route->setRedirectType($parameters['redirect-type']); |
|
244 | 244 | |
245 | - if ( !empty($parameters['error-code']) ) $route->setErrorCode($parameters['error-code']); |
|
246 | - if ( !empty($parameters['error-message']) ) $route->setErrorMessage($parameters['error-message']); |
|
245 | + if (!empty($parameters['error-code'])) $route->setErrorCode($parameters['error-code']); |
|
246 | + if (!empty($parameters['error-message'])) $route->setErrorMessage($parameters['error-message']); |
|
247 | 247 | |
248 | 248 | } |
249 | 249 |