@@ -95,6 +95,9 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | + /** |
|
| 99 | + * @return Configuration |
|
| 100 | + */ |
|
| 98 | 101 | public function configuration() { |
| 99 | 102 | |
| 100 | 103 | if (empty($this->configuration)) { |
@@ -131,6 +134,9 @@ discard block |
||
| 131 | 134 | |
| 132 | 135 | } |
| 133 | 136 | |
| 137 | + /** |
|
| 138 | + * @return Request |
|
| 139 | + */ |
|
| 134 | 140 | public function request() { |
| 135 | 141 | |
| 136 | 142 | if (empty($this->request)) { |
@@ -143,6 +149,9 @@ discard block |
||
| 143 | 149 | |
| 144 | 150 | } |
| 145 | 151 | |
| 152 | + /** |
|
| 153 | + * @return RouteCollector |
|
| 154 | + */ |
|
| 146 | 155 | public function router() { |
| 147 | 156 | |
| 148 | 157 | if (empty($this->router)) { |
@@ -155,6 +164,9 @@ discard block |
||
| 155 | 164 | |
| 156 | 165 | } |
| 157 | 166 | |
| 167 | + /** |
|
| 168 | + * @return Response |
|
| 169 | + */ |
|
| 158 | 170 | public function response() { |
| 159 | 171 | |
| 160 | 172 | if (empty($this->response)) { |
@@ -167,6 +179,9 @@ discard block |
||
| 167 | 179 | |
| 168 | 180 | } |
| 169 | 181 | |
| 182 | + /** |
|
| 183 | + * @return null|Extra |
|
| 184 | + */ |
|
| 170 | 185 | public function extra() { |
| 171 | 186 | |
| 172 | 187 | if (empty($this->extra)) { |
@@ -273,6 +288,9 @@ discard block |
||
| 273 | 288 | |
| 274 | 289 | } |
| 275 | 290 | |
| 291 | + /** |
|
| 292 | + * @param string $name |
|
| 293 | + */ |
|
| 276 | 294 | private function emitServiceSpecializedEvents($name) { |
| 277 | 295 | |
| 278 | 296 | $this->logger()->debug("Emitting $name service-event."); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | if (empty($this->configuration)) { |
| 101 | 101 | |
| 102 | - $this->configuration = new Configuration( DefaultConfiguration::get() ); |
|
| 102 | + $this->configuration = new Configuration(DefaultConfiguration::get()); |
|
| 103 | 103 | |
| 104 | 104 | } |
| 105 | 105 | |
@@ -199,9 +199,9 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | $this->logger()->debug("Emitting global dispatcher event."); |
| 201 | 201 | |
| 202 | - $this->events()->emit( new DispatcherEvent($this) ); |
|
| 202 | + $this->events()->emit(new DispatcherEvent($this)); |
|
| 203 | 203 | |
| 204 | - if ( $this->configuration()->get('enabled') === false ) { |
|
| 204 | + if ($this->configuration()->get('enabled') === false) { |
|
| 205 | 205 | |
| 206 | 206 | $this->logger()->debug("Dispatcher disabled, shutting down gracefully."); |
| 207 | 207 | |
@@ -217,11 +217,11 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.request') ); |
|
| 220 | + $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.request')); |
|
| 221 | 221 | |
| 222 | - $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.request.'.$this->request()->method()->get()) ); |
|
| 222 | + $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.request.'.$this->request()->method()->get())); |
|
| 223 | 223 | |
| 224 | - $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.request.#') ); |
|
| 224 | + $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.request.#')); |
|
| 225 | 225 | |
| 226 | 226 | $this->logger()->debug("Starting router."); |
| 227 | 227 | |
@@ -245,13 +245,13 @@ discard block |
||
| 245 | 245 | |
| 246 | 246 | $this->logger()->debug("Route acquired, type $route_type directed to $route_service."); |
| 247 | 247 | |
| 248 | - $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.route') ); |
|
| 248 | + $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.route')); |
|
| 249 | 249 | |
| 250 | - $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.route.'.$route_type) ); |
|
| 250 | + $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.route.'.$route_type)); |
|
| 251 | 251 | |
| 252 | - $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.route.'.$route_service) ); |
|
| 252 | + $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.route.'.$route_service)); |
|
| 253 | 253 | |
| 254 | - $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.route.#') ); |
|
| 254 | + $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.route.#')); |
|
| 255 | 255 | |
| 256 | 256 | // translate route to service |
| 257 | 257 | |
@@ -307,11 +307,11 @@ discard block |
||
| 307 | 307 | |
| 308 | 308 | private function shutdown() { |
| 309 | 309 | |
| 310 | - $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.response') ); |
|
| 310 | + $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.response')); |
|
| 311 | 311 | |
| 312 | - $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.response.'.$this->response()->status()->get()) ); |
|
| 312 | + $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.response.'.$this->response()->status()->get())); |
|
| 313 | 313 | |
| 314 | - $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.response.#') ); |
|
| 314 | + $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.response.#')); |
|
| 315 | 315 | |
| 316 | 316 | $this->logger()->debug("Composing return value."); |
| 317 | 317 | |
@@ -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 | |
@@ -250,7 +251,9 @@ discard block |
||
| 250 | 251 | |
| 251 | 252 | $routes = $this->cache->get("dispatcher_routes"); |
| 252 | 253 | |
| 253 | - if (is_null($routes)) return null; |
|
| 254 | + if (is_null($routes)) { |
|
| 255 | + return null; |
|
| 256 | + } |
|
| 254 | 257 | |
| 255 | 258 | $this->table->routes($routes); |
| 256 | 259 | |
@@ -317,7 +320,10 @@ discard block |
||
| 317 | 320 | */ |
| 318 | 321 | if (preg_match('/^' . $value['regex'] . '$/', $bits[$key], $matches)) { |
| 319 | 322 | |
| 320 | - if (count($matches) == 1) $matches = $matches[0]; // This is the case where no backreferences are present or available. |
|
| 323 | + if (count($matches) == 1) { |
|
| 324 | + $matches = $matches[0]; |
|
| 325 | + } |
|
| 326 | + // This is the case where no backreferences are present or available. |
|
| 321 | 327 | |
| 322 | 328 | // The extracted value (with any backreference available) is added to the query parameters. |
| 323 | 329 | $this->request->query()->set($key, $matches); |