| Conditions | 12 |
| Paths | 36 |
| Total Lines | 39 |
| Code Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 100 | protected function renderConfigs($configIDs, $input, $output) { |
||
| 101 | $renderTable = $input->getOption('output') === 'table' or $input->getOption('output') === null; |
||
| 102 | $showPassword = $input->getOption('show-password'); |
||
| 103 | |||
| 104 | $configs = []; |
||
| 105 | foreach ($configIDs as $id) { |
||
| 106 | $configHolder = new Configuration($id); |
||
| 107 | $configuration = $configHolder->getConfiguration(); |
||
| 108 | ksort($configuration); |
||
| 109 | |||
| 110 | $rows = []; |
||
| 111 | if ($renderTable) { |
||
| 112 | foreach ($configuration as $key => $value) { |
||
| 113 | if (is_array($value)) { |
||
| 114 | $value = implode(';', $value); |
||
| 115 | } |
||
| 116 | if ($key === 'ldapAgentPassword' && !$showPassword) { |
||
| 117 | $rows[] = [$key, '***']; |
||
| 118 | } else { |
||
| 119 | $rows[] = [$key, $value]; |
||
| 120 | } |
||
| 121 | } |
||
| 122 | $table = new Table($output); |
||
| 123 | $table->setHeaders(['Configuration', $id]); |
||
| 124 | $table->setRows($rows); |
||
| 125 | $table->render(); |
||
| 126 | } else { |
||
| 127 | foreach ($configuration as $key => $value) { |
||
| 128 | if ($key === 'ldapAgentPassword' && !$showPassword) { |
||
| 129 | $rows[$key] = '***'; |
||
| 130 | } else { |
||
| 131 | $rows[$key] = $value; |
||
| 132 | } |
||
| 133 | } |
||
| 134 | $configs[$id] = $rows; |
||
| 135 | } |
||
| 136 | } |
||
| 137 | if (!$renderTable) { |
||
| 138 | $this->writeArrayInOutputFormat($input, $output, $configs); |
||
| 139 | } |
||
| 142 |