| Conditions | 12 | 
| Paths | 432 | 
| Total Lines | 67 | 
| Code Lines | 43 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 2 | ||
| Bugs | 0 | 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 | ||
| 70 | public function sortable($pagination, $title, $key, $options = array(), $params = array()) | ||
| 71 |     { | ||
| 72 | $options = array_merge(array( | ||
| 73 | 'absolute' => false, | ||
| 74 | 'translationParameters' => array(), | ||
| 75 | 'translationDomain' => null, | ||
| 76 | 'translationCount' => null, | ||
| 77 | ), $options); | ||
| 78 | |||
| 79 | $params = array_merge($pagination->getParams(), $params); | ||
| 80 | |||
| 81 |         $direction = isset($options[$pagination->getPaginatorOption('sortDirectionParameterName')]) | ||
| 82 |             ? $options[$pagination->getPaginatorOption('sortDirectionParameterName')] | ||
| 83 | : (isset($options['defaultDirection']) ? $options['defaultDirection'] : 'asc') | ||
| 84 | ; | ||
| 85 | |||
| 86 | $sorted = $pagination->isSorted($key, $params); | ||
| 87 | |||
| 88 |         if ($sorted) { | ||
| 89 |             $direction = $params[$pagination->getPaginatorOption('sortDirectionParameterName')]; | ||
| 90 | $direction = (strtolower($direction) == 'asc') ? 'desc' : 'asc'; | ||
| 91 | $class = $direction == 'asc' ? 'desc' : 'asc'; | ||
| 92 | |||
| 93 |             if (isset($options['class'])) { | ||
| 94 | $options['class'] .= ' ' . $class; | ||
| 95 |             } else { | ||
| 96 | $options['class'] = $class; | ||
| 97 | } | ||
| 98 |         } else { | ||
| 99 | $options['class'] = 'sortable'; | ||
| 100 | } | ||
| 101 | |||
| 102 |         if (is_array($title) && array_key_exists($direction, $title)) { | ||
| 103 | $title = $title[$direction]; | ||
| 104 | } | ||
| 105 | |||
| 106 | $params = array_merge( | ||
| 107 | $params, | ||
| 108 | array( | ||
| 109 |                 $pagination->getPaginatorOption('sortFieldParameterName') => $key, | ||
| 110 |                 $pagination->getPaginatorOption('sortDirectionParameterName') => $direction, | ||
| 111 |                 $pagination->getPaginatorOption('pageParameterName') => 1 // reset to 1 on sort | ||
| 112 | ) | ||
| 113 | ); | ||
| 114 | |||
| 115 | $options['href'] = $this->urlGenerator->generate($pagination->getRoute(), $params, $options['absolute']); | ||
| 116 | |||
| 117 |         if (null !== $options['translationDomain']) { | ||
| 118 |             if (null !== $options['translationCount']) { | ||
| 119 | $title = $this->translator->transChoice($title, $options['translationCount'], $options['translationParameters'], $options['translationDomain']); | ||
| 120 |             } else { | ||
| 121 | $title = $this->translator->trans($title, $options['translationParameters'], $options['translationDomain']); | ||
| 122 | } | ||
| 123 | } | ||
| 124 | |||
| 125 |         if (!isset($options['title'])) { | ||
| 126 | $options['title'] = $title; | ||
| 127 | } | ||
| 128 | |||
| 129 | unset($options['absolute'], $options['translationDomain'], $options['translationParameters']); | ||
| 130 | |||
| 131 | return array_merge( | ||
| 132 | $pagination->getPaginatorOptions(), | ||
| 133 | $pagination->getCustomParameters(), | ||
| 134 |             compact('options', 'title', 'direction', 'sorted', 'key') | ||
| 135 | ); | ||
| 136 | } | ||
| 137 | |||
| 186 | 
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.