| Conditions | 10 |
| Paths | 6 |
| Total Lines | 66 |
| Code Lines | 39 |
| 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 |
||
| 230 | private function getServersGroups($recordset = false, $group_id = false) |
||
|
1 ignored issue
–
show
|
|||
| 231 | { |
||
| 232 | $lang = $this->lang; |
||
| 233 | $grps = []; |
||
| 234 | |||
| 235 | if (isset($this->conf['srv_groups'])) { |
||
| 236 | foreach ($this->conf['srv_groups'] as $i => $group) { |
||
| 237 | if ( |
||
| 238 | (($group_id === false) and (!isset($group['parents']))) /* root */ |
||
|
1 ignored issue
–
show
|
|||
| 239 | or ( |
||
| 240 | ($group_id !== false) |
||
|
2 ignored issues
–
show
|
|||
| 241 | and isset($group['parents']) |
||
|
1 ignored issue
–
show
|
|||
| 242 | and in_array($group_id, explode( |
||
|
2 ignored issues
–
show
|
|||
| 243 | ',', |
||
| 244 | preg_replace('/\s/', '', $group['parents']) |
||
| 245 | ), true) |
||
|
1 ignored issue
–
show
|
|||
| 246 | ) /* nested group */ |
||
|
1 ignored issue
–
show
|
|||
| 247 | ) { |
||
| 248 | $grps[$i] = [ |
||
| 249 | 'id' => $i, |
||
| 250 | 'desc' => $group['desc'], |
||
| 251 | 'icon' => 'Servers', |
||
| 252 | 'action' => Decorator::url( |
||
| 253 | 'servers', |
||
| 254 | [ |
||
| 255 | 'group' => Decorator::field('id'), |
||
| 256 | ] |
||
| 257 | ), |
||
| 258 | 'branch' => Decorator::url( |
||
| 259 | 'servers', |
||
| 260 | [ |
||
| 261 | 'action' => 'tree', |
||
| 262 | 'group' => $i, |
||
| 263 | ] |
||
| 264 | ), |
||
| 265 | ]; |
||
| 266 | } |
||
| 267 | } |
||
| 268 | |||
| 269 | if ($group_id === false) { |
||
| 270 | $grps['all'] = [ |
||
| 271 | 'id' => 'all', |
||
| 272 | 'desc' => $lang['strallservers'], |
||
| 273 | 'icon' => 'Servers', |
||
| 274 | 'action' => Decorator::url( |
||
| 275 | 'servers', |
||
| 276 | [ |
||
| 277 | 'group' => Decorator::field('id'), |
||
| 278 | ] |
||
| 279 | ), |
||
| 280 | 'branch' => Decorator::url( |
||
| 281 | 'servers', |
||
| 282 | [ |
||
| 283 | 'action' => 'tree', |
||
| 284 | 'group' => 'all', |
||
| 285 | ] |
||
| 286 | ), |
||
| 287 | ]; |
||
| 288 | } |
||
| 289 | } |
||
| 290 | |||
| 291 | if ($recordset) { |
||
| 292 | return new \PHPPgAdmin\ArrayRecordSet($grps); |
||
| 293 | } |
||
| 294 | |||
| 295 | return $grps; |
||
| 296 | } |
||
| 298 |