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