| Conditions | 2 |
| Paths | 2 |
| Total Lines | 51 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 7 | ||
| Bugs | 2 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php namespace Comodojo\Dispatcher; |
||
| 134 | public function dispatch() { |
||
| 135 | |||
| 136 | $this->events->emit( new DispatcherEvent($this) ); |
||
| 137 | |||
| 138 | if ( $this->configuration()->get('dispatcher-enabled') === false ) { |
||
| 139 | |||
| 140 | $status = $this->configuration()->get('dispatcher-disabled-status'); |
||
| 141 | |||
| 142 | $content = $this->configuration()->get('dispatcher-disabled-message'); |
||
| 143 | |||
| 144 | $this->response()->status()->set($status); |
||
| 145 | |||
| 146 | $this->response()->content()->set($content); |
||
| 147 | |||
| 148 | } else { |
||
| 149 | |||
| 150 | $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.request') ); |
||
| 151 | |||
| 152 | $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.request.'.$this->request->method()->get()) ); |
||
| 153 | |||
| 154 | $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.request.#') ); |
||
| 155 | |||
| 156 | $this->router->route($this->request); |
||
| 157 | |||
| 158 | $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route') ); |
||
| 159 | |||
| 160 | $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route.'.$this->router->getType()) ); |
||
| 161 | |||
| 162 | $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route.'.$this->router->getService()) ); |
||
| 163 | |||
| 164 | $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route.#') ); |
||
| 165 | |||
| 166 | // translate route to service |
||
| 167 | |||
| 168 | $this->router->compose($this->response); |
||
| 169 | |||
| 170 | $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.response') ); |
||
| 171 | |||
| 172 | $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.response.'.$this->response->status()->get()) ); |
||
| 173 | |||
| 174 | $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.response.#') ); |
||
| 175 | |||
| 176 | } |
||
| 177 | |||
| 178 | $return = Processor::parse($this->configuration, $this->logger, $this->response); |
||
| 179 | |||
| 180 | ob_end_clean(); |
||
| 181 | |||
| 182 | return $return; |
||
| 183 | |||
| 184 | } |
||
| 185 | |||
| 200 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.