| Conditions | 7 |
| Paths | 8 |
| Total Lines | 74 |
| Code Lines | 49 |
| 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 |
||
| 69 | public function doDefault($msg = '') |
||
|
1 ignored issue
–
show
|
|||
| 70 | { |
||
| 71 | $lang = $this->lang; |
||
| 72 | |||
| 73 | $this->printTabs('root', 'servers'); |
||
| 74 | $this->printMsg($msg); |
||
| 75 | $group = isset($_GET['group']) ? $_GET['group'] : false; |
||
| 76 | |||
| 77 | $groups = $this->misc->getServersGroups(true, $group); |
||
| 78 | $columns = [ |
||
| 79 | 'group' => [ |
||
| 80 | 'title' => $lang['strgroup'], |
||
| 81 | 'field' => Decorator::field('desc'), |
||
| 82 | 'url' => 'servers.php?', |
||
| 83 | 'vars' => ['group' => 'id'], |
||
| 84 | ], |
||
| 85 | ]; |
||
| 86 | $actions = []; |
||
| 87 | if ((false !== $group) && (isset($this->conf['srv_groups'][$group])) && ($groups->recordCount() > 0)) { |
||
| 88 | $this->printTitle(sprintf($lang['strgroupgroups'], htmlentities($this->conf['srv_groups'][$group]['desc'], ENT_QUOTES, 'UTF-8'))); |
||
| 89 | } |
||
| 90 | $this->printTable($groups, $columns, $actions, $this->table_place); |
||
| 91 | $servers = $this->misc->getServers(true, $group); |
||
| 92 | |||
| 93 | $columns = [ |
||
| 94 | 'server' => [ |
||
| 95 | 'title' => $lang['strserver'], |
||
| 96 | 'field' => Decorator::field('desc'), |
||
| 97 | 'url' => \SUBFOLDER . '/redirect/server?', |
||
| 98 | 'vars' => ['server' => 'id'], |
||
| 99 | ], |
||
| 100 | 'host' => [ |
||
| 101 | 'title' => $lang['strhost'], |
||
| 102 | 'field' => Decorator::field('host'), |
||
| 103 | ], |
||
| 104 | 'port' => [ |
||
| 105 | 'title' => $lang['strport'], |
||
| 106 | 'field' => Decorator::field('port'), |
||
| 107 | ], |
||
| 108 | 'username' => [ |
||
| 109 | 'title' => $lang['strusername'], |
||
| 110 | 'field' => Decorator::field('username'), |
||
| 111 | ], |
||
| 112 | 'actions' => [ |
||
| 113 | 'title' => $lang['stractions'], |
||
| 114 | ], |
||
| 115 | ]; |
||
| 116 | |||
| 117 | $actions = [ |
||
| 118 | 'logout' => [ |
||
| 119 | 'content' => $lang['strlogout'], |
||
| 120 | 'attr' => [ |
||
| 121 | 'href' => [ |
||
| 122 | 'url' => 'servers.php', |
||
| 123 | 'urlvars' => [ |
||
| 124 | 'action' => 'logout', |
||
| 125 | 'logoutServer' => Decorator::field('id'), |
||
| 126 | ], |
||
| 127 | ], |
||
| 128 | ], |
||
| 129 | ], |
||
| 130 | ]; |
||
| 131 | |||
| 132 | $svPre = function (&$rowdata) use ($actions) { |
||
| 133 | $actions['logout']['disable'] = empty($rowdata->fields['username']); |
||
| 134 | |||
| 135 | return $actions; |
||
| 136 | }; |
||
| 137 | |||
| 138 | if ((false !== $group) and isset($this->conf['srv_groups'][$group])) { |
||
| 139 | $this->printTitle(sprintf($lang['strgroupservers'], htmlentities($this->conf['srv_groups'][$group]['desc'], ENT_QUOTES, 'UTF-8')), null); |
||
| 140 | $actions['logout']['attr']['href']['urlvars']['group'] = $group; |
||
| 141 | } |
||
| 142 | echo $this->printTable($servers, $columns, $actions, $this->table_place, $lang['strnoobjects'], $svPre); |
||
| 143 | } |
||
| 209 |