| Conditions | 11 |
| Paths | 133 |
| Total Lines | 50 |
| Code Lines | 23 |
| Lines | 3 |
| Ratio | 6 % |
| Changes | 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 Anomaly\Streams\Platform\Ui\Table\Component\View\Command; |
||
| 41 | public function handle(Request $request, ViewHandler $handler) |
||
| 42 | { |
||
| 43 | $table = $this->builder->getTable(); |
||
| 44 | $options = $table->getOptions(); |
||
| 45 | $views = $table->getViews(); |
||
| 46 | |||
| 47 | if ($views->active()) { |
||
| 48 | return; |
||
| 49 | } |
||
| 50 | |||
| 51 | View Code Duplication | if ($view = $views->findBySlug($request->get($options->get('prefix') . 'view'))) { |
|
| 52 | $view->setActive(true); |
||
| 53 | } |
||
| 54 | |||
| 55 | if (!$view && $view = $views->first()) { |
||
| 56 | $view->setActive(true); |
||
| 57 | } |
||
| 58 | |||
| 59 | // Nothing to do. |
||
| 60 | if (!$view) { |
||
| 61 | return; |
||
| 62 | } |
||
| 63 | |||
| 64 | // Set filters from active view. |
||
| 65 | if (($filters = $view->getFilters()) !== null) { |
||
| 66 | $this->builder->setFilters($filters); |
||
| 67 | } |
||
| 68 | |||
| 69 | // Set columns from active view. |
||
| 70 | if (($columns = $view->getColumns()) !== null) { |
||
| 71 | $this->builder->setColumns($columns); |
||
| 72 | } |
||
| 73 | |||
| 74 | // Set buttons from active view. |
||
| 75 | if (($buttons = $view->getButtons()) !== null) { |
||
| 76 | $this->builder->setButtons($buttons); |
||
| 77 | } |
||
| 78 | |||
| 79 | // Set actions from active view. |
||
| 80 | if (($actions = $view->getActions()) !== null) { |
||
| 81 | $this->builder->setActions($actions); |
||
| 82 | } |
||
| 83 | |||
| 84 | // Set options from active view. |
||
| 85 | if (($options = $view->getOptions()) !== null) { |
||
| 86 | $this->builder->setOptions($options); |
||
| 87 | } |
||
| 88 | |||
| 89 | $handler->handle($this->builder, $view); |
||
| 90 | } |
||
| 91 | } |
||
| 92 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.