Conditions | 8 |
Paths | 36 |
Total Lines | 151 |
Code Lines | 103 |
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 = '', $isTable = true): void |
||
70 | { |
||
71 | if (!isset($_REQUEST['table']) || empty($_REQUEST['table'])) { |
||
72 | $isTable = false; |
||
73 | } |
||
74 | $data = $this->misc->getDatabaseAccessor(); |
||
75 | |||
76 | $attPre = static function (&$rowdata) use ($data): void { |
||
77 | $rowdata->fields['+type'] = $data->formatType($rowdata->fields['type'], $rowdata->fields['atttypmod']); |
||
78 | }; |
||
79 | |||
80 | if (empty($_REQUEST['column'])) { |
||
81 | $msg .= "<br/>{$this->lang['strnoobjects']}"; |
||
82 | } |
||
83 | |||
84 | $this->printTrail('column'); |
||
85 | //$this->printTitle($this->lang['strcolprop']); |
||
86 | $this->printTabs('column', 'properties'); |
||
87 | $this->printMsg($msg); |
||
88 | |||
89 | if (!empty($_REQUEST['column'])) { |
||
90 | // Get table |
||
91 | $tdata = $data->getTable($this->tableName); |
||
92 | // Get columns |
||
93 | $attrs = $data->getTableAttributes($this->tableName, $_REQUEST['column']); |
||
94 | |||
95 | // Show comment if any |
||
96 | if (null !== $attrs->fields['comment']) { |
||
97 | echo '<p class="comment">', $this->misc->printVal($attrs->fields['comment']), '</p>' . \PHP_EOL; |
||
98 | } |
||
99 | |||
100 | $column = [ |
||
101 | 'column' => [ |
||
102 | 'title' => $this->lang['strcolumn'], |
||
103 | 'field' => Decorator::field('attname'), |
||
104 | ], |
||
105 | 'type' => [ |
||
106 | 'title' => $this->lang['strtype'], |
||
107 | 'field' => Decorator::field('+type'), |
||
108 | ], |
||
109 | ]; |
||
110 | |||
111 | if ($isTable) { |
||
112 | $column['notnull'] = [ |
||
113 | 'title' => $this->lang['strnotnull'], |
||
114 | 'field' => Decorator::field('attnotnull'), |
||
115 | 'type' => 'bool', |
||
116 | 'params' => ['true' => 'NOT NULL', 'false' => ''], |
||
117 | ]; |
||
118 | $column['default'] = [ |
||
119 | 'title' => $this->lang['strdefault'], |
||
120 | 'field' => Decorator::field('adsrc'), |
||
121 | ]; |
||
122 | } |
||
123 | |||
124 | $actions = []; |
||
125 | echo $this->printTable($attrs, $column, $actions, $this->table_place, $this->lang['strnodata'], $attPre); |
||
126 | |||
127 | echo '<br />' . \PHP_EOL; |
||
128 | |||
129 | $f_attname = $_REQUEST['column']; |
||
130 | $f_table = $this->tableName; |
||
131 | $f_schema = $data->_schema; |
||
132 | $data->fieldClean($f_attname); |
||
133 | $data->fieldClean($f_table); |
||
134 | $data->fieldClean($f_schema); |
||
135 | |||
136 | if ($isTable) { |
||
137 | $navlinks = [ |
||
138 | 'browse' => [ |
||
139 | 'attr' => [ |
||
140 | 'href' => [ |
||
141 | 'url' => 'display', |
||
142 | 'method' => 'post', |
||
143 | 'urlvars' => [ |
||
144 | 'subject' => 'column', |
||
145 | 'server' => $_REQUEST['server'], |
||
146 | 'database' => $_REQUEST['database'], |
||
147 | 'schema' => $_REQUEST['schema'], |
||
148 | 'table' => $this->tableName, |
||
149 | 'column' => $_REQUEST['column'], |
||
150 | 'return' => 'column', |
||
151 | 'f_attname' => $f_attname, |
||
152 | 'f_table' => $f_table, |
||
153 | 'f_schema' => $f_schema, |
||
154 | ], |
||
155 | ], |
||
156 | ], |
||
157 | 'content' => $this->lang['strbrowse'], |
||
158 | ], |
||
159 | 'alter' => [ |
||
160 | 'attr' => [ |
||
161 | 'href' => [ |
||
162 | 'url' => 'colproperties', |
||
163 | 'urlvars' => [ |
||
164 | 'action' => 'properties', |
||
165 | 'server' => $_REQUEST['server'], |
||
166 | 'database' => $_REQUEST['database'], |
||
167 | 'schema' => $_REQUEST['schema'], |
||
168 | 'table' => $this->tableName, |
||
169 | 'column' => $_REQUEST['column'], |
||
170 | ], |
||
171 | ], |
||
172 | ], |
||
173 | 'content' => $this->lang['stralter'], |
||
174 | ], |
||
175 | 'drop' => [ |
||
176 | 'attr' => [ |
||
177 | 'href' => [ |
||
178 | 'url' => 'tblproperties', |
||
179 | 'urlvars' => [ |
||
180 | 'action' => 'confirm_drop', |
||
181 | 'server' => $_REQUEST['server'], |
||
182 | 'database' => $_REQUEST['database'], |
||
183 | 'schema' => $_REQUEST['schema'], |
||
184 | 'table' => $this->tableName, |
||
185 | 'column' => $_REQUEST['column'], |
||
186 | ], |
||
187 | ], |
||
188 | ], |
||
189 | 'content' => $this->lang['strdrop'], |
||
190 | ], |
||
191 | ]; |
||
192 | } else { |
||
193 | // Browse link |
||
194 | $navlinks = [ |
||
195 | 'browse' => [ |
||
196 | 'attr' => [ |
||
197 | 'href' => [ |
||
198 | 'url' => 'display', |
||
199 | 'method' => 'post', |
||
200 | 'urlvars' => [ |
||
201 | 'subject' => 'column', |
||
202 | 'server' => $_REQUEST['server'], |
||
203 | 'database' => $_REQUEST['database'], |
||
204 | 'schema' => $_REQUEST['schema'], |
||
205 | 'view' => $this->tableName, |
||
206 | 'column' => $_REQUEST['column'], |
||
207 | 'return' => 'column', |
||
208 | 'f_attname' => $f_attname, |
||
209 | 'f_table' => $f_table, |
||
210 | 'f_schema' => $f_schema, |
||
211 | ], |
||
212 | ], |
||
213 | ], |
||
214 | 'content' => $this->lang['strbrowse'], |
||
215 | ], |
||
216 | ]; |
||
217 | } |
||
218 | |||
219 | $this->printNavLinks($navlinks, $this->table_place, \get_defined_vars()); |
||
220 | } |
||
406 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.