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