Conditions | 6 |
Paths | 4 |
Total Lines | 79 |
Code Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | 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 |
||
77 | public function doDefault($msg = ''): void |
||
78 | { |
||
79 | $this->printTabs('root', 'servers'); |
||
80 | $this->printMsg($msg); |
||
81 | $group = $_GET['group'] ?? false; |
||
82 | |||
83 | $groups = $this->getServersGroups(true, $group); |
||
84 | $columns = [ |
||
85 | 'group' => [ |
||
86 | 'title' => $this->lang['strgroup'], |
||
87 | 'field' => Decorator::field('desc'), |
||
88 | 'url' => 'servers?', |
||
89 | 'vars' => ['group' => 'id'], |
||
90 | ], |
||
91 | ]; |
||
92 | $actions = []; |
||
93 | |||
94 | if ((false !== $group) && |
||
95 | (isset($this->conf['srv_groups'][$group])) && |
||
96 | (0 < $groups->recordCount()) |
||
97 | ) { |
||
98 | $this->printTitle(\sprintf($this->lang['strgroupgroups'], \htmlentities($this->conf['srv_groups'][$group]['desc'], \ENT_QUOTES, 'UTF-8'))); |
||
99 | echo $this->printTable($groups, $columns, $actions, $this->table_place); |
||
100 | } |
||
101 | |||
102 | $servers = $this->getServers(true, $group); |
||
103 | |||
104 | $columns = [ |
||
105 | 'server' => [ |
||
106 | 'title' => $this->lang['strserver'], |
||
107 | 'field' => Decorator::field('desc'), |
||
108 | 'url' => \containerInstance()->subFolder . '/redirect/server?', |
||
109 | 'vars' => ['server' => 'sha'], |
||
110 | ], |
||
111 | 'host' => [ |
||
112 | 'title' => $this->lang['strhost'], |
||
113 | 'field' => Decorator::field('host'), |
||
114 | ], |
||
115 | 'port' => [ |
||
116 | 'title' => $this->lang['strport'], |
||
117 | 'field' => Decorator::field('port'), |
||
118 | ], |
||
119 | 'username' => [ |
||
120 | 'title' => $this->lang['strusername'], |
||
121 | 'field' => Decorator::field('username'), |
||
122 | ], |
||
123 | 'actions' => [ |
||
124 | 'title' => $this->lang['stractions'], |
||
125 | ], |
||
126 | ]; |
||
127 | |||
128 | $actions = [ |
||
129 | 'logout' => [ |
||
130 | 'content' => $this->lang['strlogout'], |
||
131 | 'attr' => [ |
||
132 | 'href' => [ |
||
133 | 'url' => 'servers', |
||
134 | 'urlvars' => [ |
||
135 | 'action' => 'logout', |
||
136 | 'logoutServer' => Decorator::field('sha'), |
||
137 | ], |
||
138 | ], |
||
139 | ], |
||
140 | ], |
||
141 | ]; |
||
142 | //\sha1("{$server_info['host']}:{$server_info['port']}:{$server_info['sslmode']}") |
||
143 | $svPre = static function (&$rowdata) use ($actions) { |
||
144 | $actions['logout']['disable'] = empty($rowdata->fields['username']); |
||
145 | |||
146 | return $actions; |
||
147 | }; |
||
148 | |||
149 | if ((false !== $group) && |
||
150 | isset($this->conf['srv_groups'][$group]) |
||
151 | ) { |
||
152 | $this->printTitle(\sprintf($this->lang['strgroupservers'], \htmlentities($this->conf['srv_groups'][$group]['desc'], \ENT_QUOTES, 'UTF-8')), null); |
||
153 | $actions['logout']['attr']['href']['urlvars']['group'] = $group; |
||
154 | } |
||
155 | echo $this->printTable($servers, $columns, $actions, $this->table_place, $this->lang['strnoobjects'], $svPre); |
||
156 | } |
||
284 |