Conditions | 2 |
Paths | 2 |
Total Lines | 131 |
Code Lines | 86 |
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 |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Function to save after editing a matview. |
||
103 | */ |
||
104 | public function doSaveEdit() |
||
105 | { |
||
106 | $data = $this->misc->getDatabaseAccessor(); |
||
107 | |||
108 | $status = $data->setView($_POST[$this->subject], $_POST['formDefinition'], $_POST['formComment']); |
||
109 | if (0 == $status) { |
||
110 | $this->doDefinition($this->lang['strviewupdated']); |
||
111 | } else { |
||
112 | $this->doEdit($this->lang['strviewupdatedbad']); |
||
113 | } |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Function to refresh a matview. |
||
118 | */ |
||
119 | public function doRefresh() |
||
120 | { |
||
121 | $data = $this->misc->getDatabaseAccessor(); |
||
122 | $sql = 'REFRESH MATERIALIZED VIEW ' . $_REQUEST[$this->subject]; |
||
123 | $this->prtrace($sql); |
||
124 | $status = $data->execute($sql); |
||
125 | |||
126 | if (0 == $status) { |
||
127 | $this->doDefault($this->lang['strviewupdated']); |
||
128 | } else { |
||
129 | $this->doDefault($this->lang['strviewupdatedbad']); |
||
130 | } |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * Function to allow editing of a matview. |
||
135 | * |
||
136 | * @param mixed $msg |
||
137 | */ |
||
138 | public function doEdit($msg = '') |
||
139 | { |
||
140 | $data = $this->misc->getDatabaseAccessor(); |
||
141 | |||
142 | $this->printTrail($this->subject); |
||
143 | $this->printTitle($this->lang['stredit'], 'pg.matview.alter'); |
||
144 | $this->printMsg($msg); |
||
145 | |||
146 | $viewdata = $data->getView($_REQUEST[$this->subject]); |
||
147 | |||
148 | if ($viewdata->recordCount() > 0) { |
||
149 | if (!isset($_POST['formDefinition'])) { |
||
150 | $_POST['formDefinition'] = $viewdata->fields['vwdefinition']; |
||
151 | $_POST['formComment'] = $viewdata->fields['relcomment']; |
||
152 | } |
||
153 | |||
154 | echo '<form action="' . \SUBFOLDER . "/src/views/materializedviewproperties\" method=\"post\">\n"; |
||
155 | echo "<table style=\"width: 100%\">\n"; |
||
156 | echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strdefinition']}</th>\n"; |
||
157 | echo "\t\t<td class=\"data1\"><textarea style=\"width: 100%;\" rows=\"20\" cols=\"50\" name=\"formDefinition\">", |
||
158 | htmlspecialchars($_POST['formDefinition']), "</textarea></td>\n\t</tr>\n"; |
||
159 | echo "\t<tr>\n\t\t<th class=\"data left\">{$this->lang['strcomment']}</th>\n"; |
||
160 | echo "\t\t<td class=\"data1\"><textarea rows=\"3\" cols=\"32\" name=\"formComment\">", |
||
161 | htmlspecialchars($_POST['formComment']), "</textarea></td>\n\t</tr>\n"; |
||
162 | echo "</table>\n"; |
||
163 | echo "<p><input type=\"hidden\" name=\"action\" value=\"save_edit\" />\n"; |
||
164 | echo '<input type="hidden" name="matview" value="', htmlspecialchars($_REQUEST[$this->subject]), "\" />\n"; |
||
165 | echo $this->misc->form; |
||
166 | echo "<input type=\"submit\" value=\"{$this->lang['stralter']}\" />\n"; |
||
167 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" /></p>\n"; |
||
168 | echo "</form>\n"; |
||
169 | } else { |
||
170 | echo "<p>{$this->lang['strnodata']}</p>\n"; |
||
171 | } |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * Displays a screen where they can alter a column in a matview. |
||
176 | * |
||
177 | * @param mixed $msg |
||
178 | */ |
||
179 | public function doProperties($msg = '') |
||
180 | { |
||
181 | $data = $this->misc->getDatabaseAccessor(); |
||
182 | |||
183 | if (!isset($_REQUEST['stage'])) { |
||
184 | $_REQUEST['stage'] = 1; |
||
185 | } |
||
186 | |||
187 | switch ($_REQUEST['stage']) { |
||
188 | case 1: |
||
189 | |||
190 | $this->printTrail('column'); |
||
191 | $this->printTitle($this->lang['stralter'], 'pg.column.alter'); |
||
192 | $this->printMsg($msg); |
||
193 | |||
194 | echo '<form action="' . \SUBFOLDER . "/src/views/materializedviewproperties\" method=\"post\">\n"; |
||
195 | |||
196 | // Output matview header |
||
197 | echo "<table>\n"; |
||
198 | echo "<tr><th class=\"data required\">{$this->lang['strname']}</th><th class=\"data required\">{$this->lang['strtype']}</th>"; |
||
199 | echo "<th class=\"data\">{$this->lang['strdefault']}</th><th class=\"data\">{$this->lang['strcomment']}</th></tr>"; |
||
200 | |||
201 | $column = $data->getTableAttributes($_REQUEST[$this->subject], $_REQUEST['column']); |
||
202 | |||
203 | if (!isset($_REQUEST['default'])) { |
||
204 | $_REQUEST['field'] = $column->fields['attname']; |
||
205 | $_REQUEST['default'] = $_REQUEST['olddefault'] = $column->fields['adsrc']; |
||
206 | $_REQUEST['comment'] = $column->fields['comment']; |
||
207 | } |
||
208 | |||
209 | echo '<tr><td><input name="field" size="32" value="', |
||
210 | htmlspecialchars($_REQUEST['field']), '" /></td>'; |
||
211 | |||
212 | echo '<td>', $this->misc->printVal($data->formatType($column->fields['type'], $column->fields['atttypmod'])), '</td>'; |
||
213 | echo '<td><input name="default" size="20" value="', |
||
214 | htmlspecialchars($_REQUEST['default']), '" /></td>'; |
||
215 | echo '<td><input name="comment" size="32" value="', |
||
216 | htmlspecialchars($_REQUEST['comment']), '" /></td>'; |
||
217 | |||
218 | echo "</table>\n"; |
||
219 | echo "<p><input type=\"hidden\" name=\"action\" value=\"properties\" />\n"; |
||
220 | echo "<input type=\"hidden\" name=\"stage\" value=\"2\" />\n"; |
||
221 | echo $this->misc->form; |
||
222 | echo '<input type="hidden" name="matview" value="', htmlspecialchars($_REQUEST[$this->subject]), "\" />\n"; |
||
223 | echo '<input type="hidden" name="column" value="', htmlspecialchars($_REQUEST['column']), "\" />\n"; |
||
224 | echo '<input type="hidden" name="olddefault" value="', htmlspecialchars($_REQUEST['olddefault']), "\" />\n"; |
||
225 | echo "<input type=\"submit\" value=\"{$this->lang['stralter']}\" />\n"; |
||
226 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" /></p>\n"; |
||
227 | echo "</form>\n"; |
||
228 | |||
229 | break; |
||
230 | case 2: |
||
381 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.