| Conditions | 9 |
| Paths | 53 |
| Total Lines | 66 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 130 | private function qa_report_projects() { |
||
| 131 | $ret = '<h3>Projects</h3>'; |
||
| 132 | drupal_static_reset('update_get_projects'); |
||
| 133 | $GLOBALS['conf']['update_check_disabled'] = TRUE; |
||
| 134 | $projects = update_get_projects(); |
||
| 135 | ksort($projects); |
||
| 136 | $ret .= kprint_r($projects, TRUE); |
||
| 137 | |||
| 138 | $ret .= '<h3>Modules info</h3>'; |
||
| 139 | [$modules, $projects] = Module::getInfo(); |
||
| 140 | |||
| 141 | $header = [ |
||
| 142 | $this->t('Project'), |
||
| 143 | $this->t('Module'), |
||
| 144 | $this->t('Module status'), |
||
| 145 | $this->t('Project status'), |
||
| 146 | ]; |
||
| 147 | |||
| 148 | $rows = []; |
||
| 149 | $previous_project = ''; |
||
| 150 | /** @var \Drupal\qa\System\Project $project */ |
||
| 151 | foreach ($projects as $name => $project) { |
||
| 152 | $row = []; |
||
| 153 | $project_cell = ['data' => $name,]; |
||
| 154 | $count = $project->useCount(); |
||
| 155 | if ($count > 1) { |
||
| 156 | //$project_cell['rowspan'] = $count; |
||
| 157 | } |
||
| 158 | if ($name != $previous_project) { |
||
| 159 | $previous_project = $name; |
||
| 160 | } |
||
| 161 | |||
| 162 | $enabled = $this->t('Enabled'); |
||
| 163 | $disabled = $this->t('Disabled'); |
||
| 164 | |||
| 165 | /** @var \Drupal\qa\System\Module $module */ |
||
| 166 | foreach (array_values($project->modules) as $index => $module) { |
||
| 167 | $row = []; |
||
| 168 | $row[] = ($index === 0) ? $project_cell : ''; |
||
| 169 | |||
| 170 | $row[] = $module->name; |
||
| 171 | $row[] = $module->isEnabled() ? $enabled : $disabled; |
||
| 172 | |||
| 173 | if ($index === 0) { |
||
| 174 | if ($count === 0) { |
||
| 175 | $last_cell = [ |
||
| 176 | 'style' => 'background-color: #ff8080', |
||
| 177 | 'data' => $count, |
||
| 178 | ]; |
||
| 179 | } |
||
| 180 | else { |
||
| 181 | $last_cell = $count; |
||
| 182 | } |
||
| 183 | } |
||
| 184 | else { |
||
| 185 | $last_cell = ''; |
||
| 186 | } |
||
| 187 | $row[] = $last_cell; |
||
| 188 | |||
| 189 | $rows[] = $row; |
||
| 190 | } |
||
| 191 | } |
||
| 192 | return [ |
||
| 193 | '#theme' => 'table', |
||
| 194 | '#header' => $header, |
||
| 195 | '#rows' => $rows, |
||
| 196 | ]; |
||
| 200 |
This check looks for private methods that have been defined, but are not used inside the class.