| Conditions | 16 |
| Paths | 256 |
| Total Lines | 59 |
| Code Lines | 34 |
| 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 |
||
| 155 | protected function createOptionalWindows(): void |
||
| 156 | { |
||
| 157 | $windowIndex = 4; |
||
| 158 | |||
| 159 | // htop |
||
| 160 | if ((int) Settings::settingValue('htop') === 1 && $this->commandExists('htop')) { |
||
| 161 | $this->paneManager->createWindow($windowIndex, 'htop'); |
||
| 162 | $this->paneManager->respawnPane("{$windowIndex}.0", 'htop'); |
||
| 163 | $windowIndex++; |
||
| 164 | } |
||
| 165 | |||
| 166 | // nmon |
||
| 167 | if ((int) Settings::settingValue('nmon') === 1 && $this->commandExists('nmon')) { |
||
| 168 | $this->paneManager->createWindow($windowIndex, 'nmon'); |
||
| 169 | $this->paneManager->respawnPane("{$windowIndex}.0", 'nmon -t'); |
||
| 170 | $windowIndex++; |
||
| 171 | } |
||
| 172 | |||
| 173 | // vnstat |
||
| 174 | if ((int) Settings::settingValue('vnstat') === 1 && $this->commandExists('vnstat')) { |
||
| 175 | $vnstatArgs = Settings::settingValue('vnstat_args') ?? ''; |
||
| 176 | $this->paneManager->createWindow($windowIndex, 'vnstat'); |
||
| 177 | $this->paneManager->respawnPane("{$windowIndex}.0", "watch -n10 'vnstat {$vnstatArgs}'"); |
||
| 178 | $windowIndex++; |
||
| 179 | } |
||
| 180 | |||
| 181 | // tcptrack |
||
| 182 | if ((int) Settings::settingValue('tcptrack') === 1 && $this->commandExists('tcptrack')) { |
||
| 183 | $tcptrackArgs = Settings::settingValue('tcptrack_args') ?? ''; |
||
| 184 | $this->paneManager->createWindow($windowIndex, 'tcptrack'); |
||
| 185 | $this->paneManager->respawnPane("{$windowIndex}.0", "tcptrack {$tcptrackArgs}"); |
||
| 186 | $windowIndex++; |
||
| 187 | } |
||
| 188 | |||
| 189 | // bwm-ng |
||
| 190 | if ((int) Settings::settingValue('bwmng') === 1 && $this->commandExists('bwm-ng')) { |
||
| 191 | $this->paneManager->createWindow($windowIndex, 'bwm-ng'); |
||
| 192 | $this->paneManager->respawnPane("{$windowIndex}.0", 'bwm-ng'); |
||
| 193 | $windowIndex++; |
||
| 194 | } |
||
| 195 | |||
| 196 | // mytop |
||
| 197 | if ((int) Settings::settingValue('mytop') === 1 && $this->commandExists('mytop')) { |
||
| 198 | $this->paneManager->createWindow($windowIndex, 'mytop'); |
||
| 199 | $this->paneManager->respawnPane("{$windowIndex}.0", 'mytop -u'); |
||
| 200 | $windowIndex++; |
||
| 201 | } |
||
| 202 | |||
| 203 | // redis-stat |
||
| 204 | if ((int) Settings::settingValue('redis') === 1 && $this->commandExists('redis-cli')) { |
||
| 205 | $this->paneManager->createWindow($windowIndex, 'redis-stat'); |
||
| 206 | $this->paneManager->respawnPane("{$windowIndex}.0", 'redis-stat --verbose --server=63790'); |
||
| 207 | $windowIndex++; |
||
| 208 | } |
||
| 209 | |||
| 210 | // bash console |
||
| 211 | if ((int) Settings::settingValue('console') === 1) { |
||
| 212 | $this->paneManager->createWindow($windowIndex, 'bash'); |
||
| 213 | $this->paneManager->respawnPane("{$windowIndex}.0", 'bash -i'); |
||
| 214 | } |
||
| 228 |