| Conditions | 37 |
| Paths | > 20000 |
| Total Lines | 188 |
| Code Lines | 135 |
| 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 |
||
| 291 | |||
| 292 | private function getHREFSubject($subject) |
||
|
1 ignored issue
–
show
|
|||
| 293 | { |
||
| 294 | $vars = $this->misc->getSubjectParams($subject); |
||
| 295 | ksort($vars['params']); |
||
| 296 | |||
| 297 | return "{$vars['url']}?" . http_build_query($vars['params'], '', '&'); |
||
| 298 | } |
||
| 299 | |||
| 300 | /** |
||
| 301 | * Create a bread crumb trail of the object hierarchy. |
||
| 302 | * |
||
| 303 | * @param null|string $subject sunkect of the trail |
||
| 304 | */ |
||
| 305 | private function _getTrail($subject = null) |
||
| 306 | { |
||
| 307 | $lang = $this->lang; |
||
| 308 | |||
| 309 | $appName = $this->misc->appName; |
||
| 310 | |||
| 311 | $trail = []; |
||
| 312 | |||
| 313 | $trail['root'] = [ |
||
| 314 | 'text' => $appName, |
||
| 315 | 'url' => SUBFOLDER . '/src/views/servers', |
||
| 316 | 'icon' => 'Introduction', |
||
| 317 | ]; |
||
| 318 | |||
| 319 | if ('root' == $subject) { |
||
| 320 | return $trail; |
||
| 321 | } |
||
| 322 | |||
| 323 | $server_info = $this->misc->getServerInfo(); |
||
| 324 | $trail['server'] = [ |
||
| 325 | 'title' => $lang['strserver'], |
||
| 326 | 'text' => $server_info['desc'], |
||
| 327 | 'url' => $this->getHREFSubject('server'), |
||
| 328 | 'help' => 'pg.server', |
||
| 329 | 'icon' => 'Server', |
||
| 330 | ]; |
||
| 331 | |||
| 332 | if ('server' == $subject) { |
||
| 333 | return $trail; |
||
| 334 | } |
||
| 335 | |||
| 336 | $database_rolename = [ |
||
| 337 | 'database' => [ |
||
| 338 | 'title' => $lang['strdatabase'], |
||
| 339 | 'subject' => 'database', |
||
| 340 | 'help' => 'pg.database', |
||
| 341 | 'icon' => 'Database', |
||
| 342 | ], |
||
| 343 | 'rolename' => [ |
||
| 344 | 'title' => $lang['strrole'], |
||
| 345 | 'subject' => 'role', |
||
| 346 | 'help' => 'pg.role', |
||
| 347 | 'icon' => 'Roles', |
||
| 348 | ], |
||
| 349 | ]; |
||
| 350 | |||
| 351 | $trail = $this->_getTrailsFromArray($trail, $database_rolename); |
||
| 352 | |||
| 353 | if (in_array($subject, ['database', 'role'])) { |
||
| 354 | return $trail; |
||
| 355 | } |
||
| 356 | |||
| 357 | $schema = [ |
||
| 358 | 'schema' => [ |
||
| 359 | 'title' => $lang['strschema'], |
||
| 360 | 'subject' => 'schema', |
||
| 361 | 'help' => 'pg.schema', |
||
| 362 | 'icon' => 'Schema', |
||
| 363 | ], |
||
| 364 | ]; |
||
| 365 | |||
| 366 | $trail = $this->_getTrailsFromArray($trail, $schema); |
||
| 367 | if ('schema' == $subject) { |
||
| 368 | return $trail; |
||
| 369 | } |
||
| 370 | |||
| 371 | $table_view_matview_fts = [ |
||
| 372 | 'table' => [ |
||
| 373 | 'title' => $lang['strtable'], |
||
| 374 | 'subject' => 'table', |
||
| 375 | 'help' => 'pg.table', |
||
| 376 | 'icon' => 'Table', |
||
| 377 | ], |
||
| 378 | 'view' => [ |
||
| 379 | 'title' => $lang['strview'], |
||
| 380 | 'subject' => 'view', |
||
| 381 | 'help' => 'pg.view', |
||
| 382 | 'icon' => 'View', |
||
| 383 | ], |
||
| 384 | 'matview' => [ |
||
| 385 | 'title' => 'M' . $lang['strview'], |
||
| 386 | 'subject' => 'matview', |
||
| 387 | 'help' => 'pg.matview', |
||
| 388 | 'icon' => 'MViews', |
||
| 389 | ], |
||
| 390 | 'ftscfg' => [ |
||
| 391 | 'title' => $lang['strftsconfig'], |
||
| 392 | 'subject' => 'ftscfg', |
||
| 393 | 'help' => 'pg.ftscfg.example', |
||
| 394 | 'icon' => 'Fts', |
||
| 395 | ], |
||
| 396 | ]; |
||
| 397 | |||
| 398 | $trail = $this->_getTrailsFromArray($trail, $table_view_matview_fts); |
||
| 399 | |||
| 400 | if (in_array($subject, ['table', 'view', 'matview', 'ftscfg'])) { |
||
| 401 | return $trail; |
||
| 402 | } |
||
| 403 | |||
| 404 | if (!is_null($subject)) { |
||
| 405 | $trail = $this->_getLastTrailPart($subject, $trail); |
||
| 406 | } |
||
| 407 | |||
| 408 | //$this->prtrace($trail); |
||
| 409 | |||
| 410 | return $trail; |
||
| 411 | } |
||
| 412 | |||
| 413 | private function _getTrailsFromArray($trail, $the_array) |
||
| 414 | { |
||
| 415 | foreach ($the_array as $key => $value) { |
||
| 416 | if (isset($_REQUEST[$key])) { |
||
| 417 | $trail[$key] = [ |
||
| 418 | 'title' => $value['title'], |
||
| 419 | 'text' => $_REQUEST[$key], |
||
| 420 | 'url' => $this->getHREFSubject($value['subject']), |
||
| 421 | 'help' => $value['help'], |
||
| 422 | 'icon' => $value['icon'], |
||
| 423 | ]; |
||
| 424 | break; |
||
| 425 | } |
||
| 426 | } |
||
| 427 | return $trail; |
||
| 428 | } |
||
| 429 | |||
| 430 | private function _getLastTrailPart($subject, $trail) |
||
| 431 | { |
||
| 432 | $lang = $this->lang; |
||
| 433 | |||
| 434 | switch ($subject) { |
||
| 435 | case 'function': |
||
| 436 | $trail[$subject] = [ |
||
| 437 | 'title' => $lang['str' . $subject], |
||
| 438 | 'text' => $_REQUEST[$subject], |
||
| 439 | 'url' => $this->getHREFSubject('function'), |
||
| 440 | 'help' => 'pg.function', |
||
| 441 | 'icon' => 'Function', |
||
| 442 | ]; |
||
| 443 | |||
| 444 | break; |
||
| 445 | case 'aggregate': |
||
| 446 | $trail[$subject] = [ |
||
| 447 | 'title' => $lang['straggregate'], |
||
| 448 | 'text' => $_REQUEST['aggrname'], |
||
| 449 | 'url' => $this->getHREFSubject('aggregate'), |
||
| 450 | 'help' => 'pg.aggregate', |
||
| 451 | 'icon' => 'Aggregate', |
||
| 452 | ]; |
||
| 453 | |||
| 454 | break; |
||
| 455 | case 'column': |
||
| 456 | $trail['column'] = [ |
||
| 457 | 'title' => $lang['strcolumn'], |
||
| 458 | 'text' => $_REQUEST['column'], |
||
| 459 | 'icon' => 'Column', |
||
| 460 | 'url' => $this->getHREFSubject('column'), |
||
| 461 | ]; |
||
| 462 | |||
| 463 | break; |
||
| 464 | default: |
||
| 465 | if (isset($_REQUEST[$subject])) { |
||
| 466 | switch ($subject) { |
||
| 467 | case 'domain': |
||
| 468 | $icon = 'Domain'; |
||
| 469 | |||
| 470 | break; |
||
| 471 | case 'sequence': |
||
| 472 | $icon = 'Sequence'; |
||
| 473 | |||
| 474 | break; |
||
| 475 | case 'type': |
||
| 476 | $icon = 'Type'; |
||
| 477 | |||
| 478 | break; |
||
| 479 | case 'operator': |
||
| 503 |