@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | public function getServiceName() { |
| 74 | 74 | |
| 75 | - return (empty($this->service))?"default":implode('.', $this->service); |
|
| 75 | + return (empty($this->service)) ? "default" : implode('.', $this->service); |
|
| 76 | 76 | |
| 77 | 77 | } |
| 78 | 78 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | $parameters = $this->parameters; |
| 98 | 98 | |
| 99 | - return (isset($parameters[$key]))?$parameters[$key]:null; |
|
| 99 | + return (isset($parameters[$key])) ? $parameters[$key] : null; |
|
| 100 | 100 | |
| 101 | 101 | } |
| 102 | 102 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $parameters = $this->request; |
| 128 | 128 | |
| 129 | - return (isset($parameters[$key]))?$parameters[$key]:null; |
|
| 129 | + return (isset($parameters[$key])) ? $parameters[$key] : null; |
|
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | $query = $this->query; |
| 171 | 171 | |
| 172 | - return isset($query[$key])?$query[$key]["required"]:false; |
|
| 172 | + return isset($query[$key]) ? $query[$key]["required"] : false; |
|
| 173 | 173 | |
| 174 | 174 | } |
| 175 | 175 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | $query = $this->query; |
| 179 | 179 | |
| 180 | - return isset($query[$key])?$query[$key]["regex"]:null; |
|
| 180 | + return isset($query[$key]) ? $query[$key]["regex"] : null; |
|
| 181 | 181 | |
| 182 | 182 | } |
| 183 | 183 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | /* if it's available a bit associated with the parameter name, it is compared against |
| 219 | 219 | * it's regular expression in order to extrect backreferences |
| 220 | 220 | */ |
| 221 | - if (preg_match('/^' . $value['regex'] . '$/', $path[$key], $matches)) { |
|
| 221 | + if (preg_match('/^'.$value['regex'].'$/', $path[$key], $matches)) { |
|
| 222 | 222 | |
| 223 | 223 | if (count($matches) == 1) $matches = $matches[0]; // This is the case where no backreferences are present or available. |
| 224 | 224 | |
@@ -87,6 +87,11 @@ |
||
| 87 | 87 | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | + /** |
|
| 91 | + * @param string $key |
|
| 92 | + * |
|
| 93 | + * @return string |
|
| 94 | + */ |
|
| 90 | 95 | public function getParameter($key) { |
| 91 | 96 | |
| 92 | 97 | $parameters = $this->parameters; |
@@ -215,7 +215,10 @@ |
||
| 215 | 215 | */ |
| 216 | 216 | if (preg_match('/^' . $value['regex'] . '$/', $path[$key], $matches)) { |
| 217 | 217 | |
| 218 | - if (count($matches) == 1) $matches = $matches[0]; // This is the case where no backreferences are present or available. |
|
| 218 | + if (count($matches) == 1) { |
|
| 219 | + $matches = $matches[0]; |
|
| 220 | + } |
|
| 221 | + // This is the case where no backreferences are present or available. |
|
| 219 | 222 | |
| 220 | 223 | // The extracted value (with any backreference available) is added to the query parameters. |
| 221 | 224 | $this->setRequestParameter($key, $matches); |
@@ -44,6 +44,9 @@ |
||
| 44 | 44 | |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | + /** |
|
| 48 | + * @return string |
|
| 49 | + */ |
|
| 47 | 50 | public function getTemporaryName() { |
| 48 | 51 | |
| 49 | 52 | return $this->tname; |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | if (!empty($this->path) && file_exists($this->path)) { |
| 110 | 110 | |
| 111 | - $local_name = "$this->path/" . ($as_slug ? $this->getSlug() : $this->getFileName()); |
|
| 111 | + $local_name = "$this->path/".($as_slug ? $this->getSlug() : $this->getFileName()); |
|
| 112 | 112 | |
| 113 | - if ( file_exists($local_name) ) { |
|
| 113 | + if (file_exists($local_name)) { |
|
| 114 | 114 | |
| 115 | 115 | $files = glob("$local_name*"); |
| 116 | 116 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if ( move_uploaded_file($this->getTemporaryName(), $local_name) ) { |
|
| 123 | + if (move_uploaded_file($this->getTemporaryName(), $local_name)) { |
|
| 124 | 124 | |
| 125 | 125 | // return file_exists($local_name); |
| 126 | 126 | return true; |
@@ -84,7 +84,9 @@ |
||
| 84 | 84 | |
| 85 | 85 | $file = $this->getTemporaryName(); |
| 86 | 86 | |
| 87 | - if (file_exists($file)) return file_get_contents($file); |
|
| 87 | + if (file_exists($file)) { |
|
| 88 | + return file_get_contents($file); |
|
| 89 | + } |
|
| 88 | 90 | |
| 89 | 91 | throw new Exception("File does not exists"); |
| 90 | 92 | |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | |
| 30 | 30 | protected $dispatcher; |
| 31 | 31 | |
| 32 | - public function __construct( Dispatcher $dispatcher ) { |
|
| 32 | + public function __construct(Dispatcher $dispatcher) { |
|
| 33 | 33 | |
| 34 | 34 | parent::__construct('dispatcher'); |
| 35 | 35 | |
@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | public function get($header = null) { |
| 30 | 30 | |
| 31 | - if ( is_null($header) ) return $this->headers; |
|
| 31 | + if (is_null($header)) return $this->headers; |
|
| 32 | 32 | |
| 33 | - else if ( array_key_exists($header, $this->headers) ) return $this->headers[$header]; |
|
| 33 | + else if (array_key_exists($header, $this->headers)) return $this->headers[$header]; |
|
| 34 | 34 | |
| 35 | 35 | else return null; |
| 36 | 36 | |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | public function getAsString($header = null) { |
| 40 | 40 | |
| 41 | - if ( is_null($header) ) { |
|
| 41 | + if (is_null($header)) { |
|
| 42 | 42 | |
| 43 | - return array_map( [$this, 'headerToString'], |
|
| 43 | + return array_map([$this, 'headerToString'], |
|
| 44 | 44 | array_keys($this->headers), |
| 45 | 45 | array_values($this->headers) |
| 46 | 46 | ); |
| 47 | 47 | |
| 48 | - } else if ( array_key_exists($header, $this->headers) ) { |
|
| 48 | + } else if (array_key_exists($header, $this->headers)) { |
|
| 49 | 49 | |
| 50 | 50 | return self::headerToString($header, $this->headers[$header]); |
| 51 | 51 | |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public function set($header, $value=null) { |
|
| 56 | + public function set($header, $value = null) { |
|
| 57 | 57 | |
| 58 | - if ( is_null($value) ) { |
|
| 58 | + if (is_null($value)) { |
|
| 59 | 59 | |
| 60 | 60 | $header = explode(":", $header); |
| 61 | 61 | |
@@ -73,13 +73,13 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | public function delete($header = null) { |
| 75 | 75 | |
| 76 | - if ( is_null($header) ) { |
|
| 76 | + if (is_null($header)) { |
|
| 77 | 77 | |
| 78 | 78 | $this->headers = array(); |
| 79 | 79 | |
| 80 | 80 | return true; |
| 81 | 81 | |
| 82 | - } else if ( array_key_exists($header, $this->headers) ) { |
|
| 82 | + } else if (array_key_exists($header, $this->headers)) { |
|
| 83 | 83 | |
| 84 | 84 | unset($this->headers[$header]); |
| 85 | 85 | |
@@ -28,11 +28,13 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | public function get($header = null) { |
| 30 | 30 | |
| 31 | - if ( is_null($header) ) return $this->headers; |
|
| 32 | - |
|
| 33 | - else if ( array_key_exists($header, $this->headers) ) return $this->headers[$header]; |
|
| 34 | - |
|
| 35 | - else return null; |
|
| 31 | + if ( is_null($header) ) { |
|
| 32 | + return $this->headers; |
|
| 33 | + } else if ( array_key_exists($header, $this->headers) ) { |
|
| 34 | + return $this->headers[$header]; |
|
| 35 | + } else { |
|
| 36 | + return null; |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | } |
| 38 | 40 | |
@@ -49,7 +51,9 @@ discard block |
||
| 49 | 51 | |
| 50 | 52 | return self::headerToString($header, $this->headers[$header]); |
| 51 | 53 | |
| 52 | - } else return null; |
|
| 54 | + } else { |
|
| 55 | + return null; |
|
| 56 | + } |
|
| 53 | 57 | |
| 54 | 58 | } |
| 55 | 59 | |
@@ -41,11 +41,11 @@ discard block |
||
| 41 | 41 | Response $response |
| 42 | 42 | ) { |
| 43 | 43 | |
| 44 | - $name = md5( (string) $request->method . (string) $request->uri ); |
|
| 44 | + $name = md5((string)$request->method.(string)$request->uri); |
|
| 45 | 45 | |
| 46 | 46 | $cache_object = $this->cache->setNamespace('dispatcherservice')->get($name); |
| 47 | 47 | |
| 48 | - if ( is_null($cache_object) ) return false; |
|
| 48 | + if (is_null($cache_object)) return false; |
|
| 49 | 49 | |
| 50 | 50 | $response->import($cache_object); |
| 51 | 51 | |
@@ -63,17 +63,17 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | $ttl = $route->getParameter('ttl'); |
| 65 | 65 | |
| 66 | - $name = md5( (string) $request->method . (string) $request->uri ); |
|
| 66 | + $name = md5((string)$request->method.(string)$request->uri); |
|
| 67 | 67 | |
| 68 | 68 | $method = $request->method->get(); |
| 69 | 69 | |
| 70 | 70 | $status = $response->status->get(); |
| 71 | 71 | |
| 72 | 72 | if ( |
| 73 | - ( $cache == 'SERVER' || $cache == 'BOTH' ) && |
|
| 73 | + ($cache == 'SERVER' || $cache == 'BOTH') && |
|
| 74 | 74 | in_array($method, self::$cachable_methods) && |
| 75 | 75 | in_array($status, self::$cachable_statuses) |
| 76 | - ){ |
|
| 76 | + ) { |
|
| 77 | 77 | |
| 78 | 78 | $this->cache |
| 79 | 79 | ->setNamespace('dispatcherservice') |
@@ -45,7 +45,9 @@ |
||
| 45 | 45 | |
| 46 | 46 | $cache_object = $this->cache->setNamespace('dispatcherservice')->get($name); |
| 47 | 47 | |
| 48 | - if ( is_null($cache_object) ) return false; |
|
| 48 | + if ( is_null($cache_object) ) { |
|
| 49 | + return false; |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | $response->import($cache_object); |
| 51 | 53 | |
@@ -192,7 +192,9 @@ |
||
| 192 | 192 | |
| 193 | 193 | if ( !empty($params) && is_array($params) ) { |
| 194 | 194 | |
| 195 | - foreach($params as $name=>$value) $this->response->headers->set($name, $value); |
|
| 195 | + foreach($params as $name=>$value) { |
|
| 196 | + $this->response->headers->set($name, $value); |
|
| 197 | + } |
|
| 196 | 198 | } |
| 197 | 199 | |
| 198 | 200 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | // init core components |
| 76 | 76 | // create new configuration object and merge configuration |
| 77 | - $configuration_object = new Configuration( DefaultConfiguration::get() ); |
|
| 77 | + $configuration_object = new Configuration(DefaultConfiguration::get()); |
|
| 78 | 78 | $configuration_object->merge($configuration); |
| 79 | 79 | $logger = is_null($logger) ? LogManager::createFromConfiguration($configuration_object)->getLogger() : $logger; |
| 80 | 80 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $this->setRaw('response', new Response($this->configuration, $this->logger)); |
| 96 | 96 | |
| 97 | 97 | } catch (Exception $e) { |
| 98 | - $this->logger->critical($e->getMessage(),$e->getTrace()); |
|
| 98 | + $this->logger->critical($e->getMessage(), $e->getTrace()); |
|
| 99 | 99 | throw $e; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | $this->logger->debug("Emitting global dispatcher event."); |
| 112 | 112 | |
| 113 | - $this->events->emit( new DispatcherEvent($this) ); |
|
| 113 | + $this->events->emit(new DispatcherEvent($this)); |
|
| 114 | 114 | |
| 115 | - if ( $this->configuration->get('enabled') === false ) { |
|
| 115 | + if ($this->configuration->get('enabled') === false) { |
|
| 116 | 116 | |
| 117 | 117 | $this->logger->debug("Dispatcher disabled, shutting down gracefully."); |
| 118 | 118 | |
@@ -130,13 +130,13 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | $cache = new ServerCache($this->cache); |
| 132 | 132 | |
| 133 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.request') ); |
|
| 133 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.request')); |
|
| 134 | 134 | |
| 135 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.request.'.$this->request->method->get()) ); |
|
| 135 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.request.'.$this->request->method->get())); |
|
| 136 | 136 | |
| 137 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.request.#') ); |
|
| 137 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.request.#')); |
|
| 138 | 138 | |
| 139 | - if ( $cache->read($this->request, $this->response) ) { |
|
| 139 | + if ($cache->read($this->request, $this->response)) { |
|
| 140 | 140 | |
| 141 | 141 | return $this->shutdown(); |
| 142 | 142 | |
@@ -164,13 +164,13 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | $this->logger->debug("Route acquired, type $route_type directed to $route_service"); |
| 166 | 166 | |
| 167 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route') ); |
|
| 167 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route')); |
|
| 168 | 168 | |
| 169 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route.'.$route_type) ); |
|
| 169 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route.'.$route_type)); |
|
| 170 | 170 | |
| 171 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route.'.$route_service) ); |
|
| 171 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route.'.$route_service)); |
|
| 172 | 172 | |
| 173 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route.#') ); |
|
| 173 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route.#')); |
|
| 174 | 174 | |
| 175 | 175 | // translate route to service |
| 176 | 176 | |
@@ -200,9 +200,9 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | $params = $route->getParameter('headers'); |
| 202 | 202 | |
| 203 | - if ( !empty($params) && is_array($params) ) { |
|
| 203 | + if (!empty($params) && is_array($params)) { |
|
| 204 | 204 | |
| 205 | - foreach($params as $name=>$value) $this->response->headers->set($name, $value); |
|
| 205 | + foreach ($params as $name=>$value) $this->response->headers->set($name, $value); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | } |
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | |
| 243 | 243 | $this->response->consolidate($this->request, $this->route); |
| 244 | 244 | |
| 245 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.response') ); |
|
| 245 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.response')); |
|
| 246 | 246 | |
| 247 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.response.'.$this->response->status->get()) ); |
|
| 247 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.response.'.$this->response->status->get())); |
|
| 248 | 248 | |
| 249 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.response.#') ); |
|
| 249 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.response.#')); |
|
| 250 | 250 | |
| 251 | 251 | $this->logger->debug("Composing return value"); |
| 252 | 252 | |
@@ -207,6 +207,9 @@ |
||
| 207 | 207 | |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | + /** |
|
| 211 | + * @param string $name |
|
| 212 | + */ |
|
| 210 | 213 | private function emitServiceSpecializedEvents($name) { |
| 211 | 214 | |
| 212 | 215 | $this->logger->debug("Emitting $name service-event"); |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $supported_methods = $this->configuration->get('supported-http-methods'); |
| 64 | 64 | |
| 65 | - if ( is_null($supported_methods) ) $supported_methods = array('GET','PUT','POST','DELETE','OPTIONS','HEAD','TRACE','CONNECT','PURGE'); |
|
| 65 | + if (is_null($supported_methods)) $supported_methods = array('GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'HEAD', 'TRACE', 'CONNECT', 'PURGE'); |
|
| 66 | 66 | |
| 67 | - if ( method_exists($this, 'any') ) { |
|
| 67 | + if (method_exists($this, 'any')) { |
|
| 68 | 68 | |
| 69 | 69 | return $supported_methods; |
| 70 | 70 | |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | $implemented_methods = array(); |
| 74 | 74 | |
| 75 | - foreach ( $supported_methods as $method ) { |
|
| 75 | + foreach ($supported_methods as $method) { |
|
| 76 | 76 | |
| 77 | - if ( method_exists($this, strtolower($method)) ) array_push($implemented_methods,$method); |
|
| 77 | + if (method_exists($this, strtolower($method))) array_push($implemented_methods, $method); |
|
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function getMethod($method) { |
| 90 | 90 | |
| 91 | - if ( method_exists($this, strtolower($method)) ) { |
|
| 91 | + if (method_exists($this, strtolower($method))) { |
|
| 92 | 92 | |
| 93 | 93 | return strtolower($method); |
| 94 | 94 | |
| 95 | - } else if ( method_exists($this, strtolower('any')) ) { |
|
| 95 | + } else if (method_exists($this, strtolower('any'))) { |
|
| 96 | 96 | |
| 97 | 97 | return 'any'; |
| 98 | 98 | |
@@ -62,7 +62,9 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $supported_methods = $this->configuration->get('supported-http-methods'); |
| 64 | 64 | |
| 65 | - if ( is_null($supported_methods) ) $supported_methods = array('GET','PUT','POST','DELETE','OPTIONS','HEAD','TRACE','CONNECT','PURGE'); |
|
| 65 | + if ( is_null($supported_methods) ) { |
|
| 66 | + $supported_methods = array('GET','PUT','POST','DELETE','OPTIONS','HEAD','TRACE','CONNECT','PURGE'); |
|
| 67 | + } |
|
| 66 | 68 | |
| 67 | 69 | if ( method_exists($this, 'any') ) { |
| 68 | 70 | |
@@ -74,7 +76,9 @@ discard block |
||
| 74 | 76 | |
| 75 | 77 | foreach ( $supported_methods as $method ) { |
| 76 | 78 | |
| 77 | - if ( method_exists($this, strtolower($method)) ) array_push($implemented_methods,$method); |
|
| 79 | + if ( method_exists($this, strtolower($method)) ) { |
|
| 80 | + array_push($implemented_methods,$method); |
|
| 81 | + } |
|
| 78 | 82 | |
| 79 | 83 | } |
| 80 | 84 | |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | |
| 37 | 37 | private static function getParameters() { |
| 38 | 38 | |
| 39 | - switch( $_SERVER['REQUEST_METHOD'] ) { |
|
| 39 | + switch ($_SERVER['REQUEST_METHOD']) { |
|
| 40 | 40 | |
| 41 | 41 | case 'GET': |
| 42 | 42 | |
@@ -127,9 +127,9 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | public function load($routes) { |
| 129 | 129 | |
| 130 | - if ( !empty($routes) ) { |
|
| 130 | + if (!empty($routes)) { |
|
| 131 | 131 | |
| 132 | - foreach( $routes as $name => $route ) { |
|
| 132 | + foreach ($routes as $name => $route) { |
|
| 133 | 133 | |
| 134 | 134 | $this->add($route['route'], $route['type'], $route['class'], $route['parameters']); |
| 135 | 135 | // $this->add($name, $route['type'], $route['class'], $route['parameters']); |
@@ -147,11 +147,11 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | private function readCache() { |
| 149 | 149 | |
| 150 | - if ( $this->configuration->get('routing-table-cache') !== true ) return; |
|
| 150 | + if ($this->configuration->get('routing-table-cache') !== true) return; |
|
| 151 | 151 | |
| 152 | 152 | $data = $this->cache->read(); |
| 153 | 153 | |
| 154 | - if ( is_null($data) ) { |
|
| 154 | + if (is_null($data)) { |
|
| 155 | 155 | |
| 156 | 156 | $this->routes = []; |
| 157 | 157 | |
@@ -167,11 +167,11 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | private function dumpCache() { |
| 169 | 169 | |
| 170 | - if ( $this->configuration->get('routing-table-cache') !== true ) return; |
|
| 170 | + if ($this->configuration->get('routing-table-cache') !== true) return; |
|
| 171 | 171 | |
| 172 | 172 | $ttl = $this->configuration->get('routing-table-ttl'); |
| 173 | 173 | |
| 174 | - if ( $this->cache->dump($this->routes, $ttl) ) { |
|
| 174 | + if ($this->cache->dump($this->routes, $ttl)) { |
|
| 175 | 175 | $this->logger->debug("Routing table saved to cache"); |
| 176 | 176 | } else { |
| 177 | 177 | $this->logger->warning("Cannot save routing table to cache"); |
@@ -188,14 +188,14 @@ discard block |
||
| 188 | 188 | ->setClassName($class) // Class to be invoked |
| 189 | 189 | ->setParameters($parameters); // Parameters passed via the composer.json configuration (cache, ttl, etc...) |
| 190 | 190 | |
| 191 | - $this->logger->debug("ROUTE: " . implode("/", $folders)); |
|
| 191 | + $this->logger->debug("ROUTE: ".implode("/", $folders)); |
|
| 192 | 192 | |
| 193 | 193 | //$this->logger->debug("PARAMETERS: " . var_export($value, true)); |
| 194 | 194 | |
| 195 | 195 | // This method generate a global regular expression which will be able to match all the URI supported by the route |
| 196 | 196 | $regex = $this->parser->read($folders, $route); |
| 197 | 197 | |
| 198 | - $this->logger->debug("ROUTE: " . $regex); |
|
| 198 | + $this->logger->debug("ROUTE: ".$regex); |
|
| 199 | 199 | |
| 200 | 200 | //$this->logger->debug("PARAMETERS: " . var_export($value, true)); |
| 201 | 201 | |
@@ -84,10 +84,11 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | $regex = $this->regex($route); |
| 86 | 86 | |
| 87 | - if (isset($this->routes[$regex])) |
|
| 88 | - return $this->routes[$regex]; |
|
| 89 | - else |
|
| 90 | - return null; |
|
| 87 | + if (isset($this->routes[$regex])) { |
|
| 88 | + return $this->routes[$regex]; |
|
| 89 | + } else { |
|
| 90 | + return null; |
|
| 91 | + } |
|
| 91 | 92 | |
| 92 | 93 | } |
| 93 | 94 | |
@@ -147,7 +148,9 @@ discard block |
||
| 147 | 148 | |
| 148 | 149 | private function readCache() { |
| 149 | 150 | |
| 150 | - if ( $this->configuration->get('routing-table-cache') !== true ) return; |
|
| 151 | + if ( $this->configuration->get('routing-table-cache') !== true ) { |
|
| 152 | + return; |
|
| 153 | + } |
|
| 151 | 154 | |
| 152 | 155 | $data = $this->cache->read(); |
| 153 | 156 | |
@@ -167,7 +170,9 @@ discard block |
||
| 167 | 170 | |
| 168 | 171 | private function dumpCache() { |
| 169 | 172 | |
| 170 | - if ( $this->configuration->get('routing-table-cache') !== true ) return; |
|
| 173 | + if ( $this->configuration->get('routing-table-cache') !== true ) { |
|
| 174 | + return; |
|
| 175 | + } |
|
| 171 | 176 | |
| 172 | 177 | $ttl = $this->configuration->get('routing-table-ttl'); |
| 173 | 178 | |