| Conditions | 19 |
| Paths | 85 |
| Total Lines | 107 |
| Code Lines | 70 |
| 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 |
||
| 270 | public function doAlter($confirm = false, $msg = '') |
||
| 271 | { |
||
| 272 | $data = $this->misc->getDatabaseAccessor(); |
||
| 273 | |||
| 274 | if ($confirm) { |
||
| 275 | $this->printTrail($this->subject); |
||
| 276 | $this->printTitle($this->lang['stralter'], 'pg.matview.alter'); |
||
| 277 | $this->printMsg($msg); |
||
| 278 | |||
| 279 | // Fetch matview info |
||
| 280 | $matview = $data->getView($_REQUEST[$this->subject]); |
||
| 281 | |||
| 282 | if ($matview->recordCount() > 0) { |
||
| 283 | if (!isset($_POST['name'])) { |
||
| 284 | $_POST['name'] = $matview->fields['relname']; |
||
| 285 | } |
||
| 286 | |||
| 287 | if (!isset($_POST['owner'])) { |
||
| 288 | $_POST['owner'] = $matview->fields['relowner']; |
||
| 289 | } |
||
| 290 | |||
| 291 | if (!isset($_POST['newschema'])) { |
||
| 292 | $_POST['newschema'] = $matview->fields['nspname']; |
||
| 293 | } |
||
| 294 | |||
| 295 | if (!isset($_POST['comment'])) { |
||
| 296 | $_POST['comment'] = $matview->fields['relcomment']; |
||
| 297 | } |
||
| 298 | |||
| 299 | echo '<form action="' . \SUBFOLDER . "/src/views/materializedviewproperties\" method=\"post\">\n"; |
||
| 300 | echo "<table>\n"; |
||
| 301 | echo "<tr><th class=\"data left required\">{$this->lang['strname']}</th>\n"; |
||
| 302 | echo '<td class="data1">'; |
||
| 303 | echo "<input name=\"name\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
||
| 304 | htmlspecialchars($_POST['name']), "\" /></td></tr>\n"; |
||
| 305 | |||
| 306 | if ($data->isSuperUser()) { |
||
| 307 | // Fetch all users |
||
| 308 | $users = $data->getUsers(); |
||
| 309 | |||
| 310 | echo "<tr><th class=\"data left required\">{$this->lang['strowner']}</th>\n"; |
||
| 311 | echo '<td class="data1"><select name="owner">'; |
||
| 312 | while (!$users->EOF) { |
||
| 313 | $uname = $users->fields['usename']; |
||
| 314 | echo '<option value="', htmlspecialchars($uname), '"', |
||
| 315 | ($uname == $_POST['owner']) ? ' selected="selected"' : '', '>', htmlspecialchars($uname), "</option>\n"; |
||
| 316 | $users->moveNext(); |
||
| 317 | } |
||
| 318 | echo "</select></td></tr>\n"; |
||
| 319 | } |
||
| 320 | |||
| 321 | if ($data->hasAlterTableSchema()) { |
||
| 322 | $schemas = $data->getSchemas(); |
||
| 323 | echo "<tr><th class=\"data left required\">{$this->lang['strschema']}</th>\n"; |
||
| 324 | echo '<td class="data1"><select name="newschema">'; |
||
| 325 | while (!$schemas->EOF) { |
||
| 326 | $schema = $schemas->fields['nspname']; |
||
| 327 | echo '<option value="', htmlspecialchars($schema), '"', |
||
| 328 | ($schema == $_POST['newschema']) ? ' selected="selected"' : '', '>', htmlspecialchars($schema), "</option>\n"; |
||
| 329 | $schemas->moveNext(); |
||
| 330 | } |
||
| 331 | echo "</select></td></tr>\n"; |
||
| 332 | } |
||
| 333 | |||
| 334 | echo "<tr><th class=\"data left\">{$this->lang['strcomment']}</th>\n"; |
||
| 335 | echo '<td class="data1">'; |
||
| 336 | echo '<textarea rows="3" cols="32" name="comment">'; |
||
| 337 | echo htmlspecialchars($_POST['comment']), "</textarea></td></tr>\n"; |
||
| 338 | echo "</table>\n"; |
||
| 339 | echo "<input type=\"hidden\" name=\"action\" value=\"alter\" />\n"; |
||
| 340 | echo '<input type="hidden" name="matview" value="', htmlspecialchars($_REQUEST[$this->subject]), "\" />\n"; |
||
| 341 | echo $this->misc->form; |
||
| 342 | echo "<p><input type=\"submit\" name=\"alter\" value=\"{$this->lang['stralter']}\" />\n"; |
||
| 343 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" /></p>\n"; |
||
| 344 | echo "</form>\n"; |
||
| 345 | } else { |
||
| 346 | echo "<p>{$this->lang['strnodata']}</p>\n"; |
||
| 347 | } |
||
| 348 | } else { |
||
| 349 | // For databases that don't allow owner change |
||
| 350 | if (!isset($_POST['owner'])) { |
||
| 351 | $_POST['owner'] = ''; |
||
| 352 | } |
||
| 353 | |||
| 354 | if (!isset($_POST['newschema'])) { |
||
| 355 | $_POST['newschema'] = null; |
||
| 356 | } |
||
| 357 | |||
| 358 | $status = $data->alterView($_POST[$this->subject], $_POST['name'], $_POST['owner'], $_POST['newschema'], $_POST['comment']); |
||
| 359 | if (0 == $status) { |
||
| 360 | // If matview has been renamed, need to change to the new name and |
||
| 361 | // reload the browser frame. |
||
| 362 | if ($_POST[$this->subject] != $_POST['name']) { |
||
| 363 | // Jump them to the new matview name |
||
| 364 | $_REQUEST[$this->subject] = $_POST['name']; |
||
| 365 | // Force a browser reload |
||
| 366 | $this->misc->setReloadBrowser(true); |
||
| 367 | } |
||
| 368 | // If schema has changed, need to change to the new schema and reload the browser |
||
| 369 | if (!empty($_POST['newschema']) && ($_POST['newschema'] != $data->_schema)) { |
||
| 370 | // Jump them to the new sequence schema |
||
| 371 | $this->misc->setCurrentSchema($_POST['newschema']); |
||
| 372 | $this->misc->setReloadBrowser(true); |
||
| 373 | } |
||
| 374 | $this->doDefault($this->lang['strviewaltered']); |
||
| 375 | } else { |
||
| 376 | $this->doAlter(true, $this->lang['strviewalteredbad']); |
||
| 377 | } |
||
| 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.