| Conditions | 11 |
| Paths | 80 |
| Total Lines | 95 |
| Code Lines | 50 |
| 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 |
||
| 239 | private function doFooter($doBody = true, $template = 'footer.twig') |
||
|
2 ignored issues
–
show
|
|||
| 240 | { |
||
| 241 | $lang = $this->lang; |
||
| 242 | $data = $this->misc->getDatabaseAccessor(); |
||
| 243 | |||
| 244 | // May as well try to time the query |
||
| 245 | if (null !== $this->start_time) { |
||
| 246 | list($usec, $sec) = explode(' ', microtime()); |
||
| 247 | $end_time = ((float) $usec + (float) $sec); |
||
| 248 | // Get duration in milliseconds, round to 3dp's |
||
| 249 | $this->duration = number_format(($end_time - $this->start_time) * 1000, 3); |
||
| 250 | } |
||
| 251 | |||
| 252 | // Reload the browser as we may have made schema changes |
||
| 253 | $this->misc->setReloadBrowser(true); |
||
| 254 | |||
| 255 | // Display duration if we know it |
||
| 256 | if (null !== $this->duration) { |
||
| 257 | echo '<p>', sprintf($lang['strruntime'], $this->duration), "</p>\n"; |
||
| 258 | } |
||
| 259 | |||
| 260 | echo "<p>{$lang['strsqlexecuted']}</p>\n"; |
||
| 261 | |||
| 262 | $navlinks = []; |
||
| 263 | $fields = [ |
||
| 264 | 'server' => $_REQUEST['server'], |
||
| 265 | 'database' => $_REQUEST['database'], |
||
| 266 | ]; |
||
| 267 | |||
| 268 | if (isset($_REQUEST['schema'])) { |
||
| 269 | $fields['schema'] = $_REQUEST['schema']; |
||
| 270 | } |
||
| 271 | |||
| 272 | // Return |
||
| 273 | if (isset($_REQUEST['return'])) { |
||
| 274 | $urlvars = $this->misc->getSubjectParams($_REQUEST['return']); |
||
| 275 | $navlinks['back'] = [ |
||
| 276 | 'attr' => [ |
||
| 277 | 'href' => [ |
||
| 278 | 'url' => $urlvars['url'], |
||
| 279 | 'urlvars' => $urlvars['params'], |
||
| 280 | ], |
||
| 281 | ], |
||
| 282 | 'content' => $lang['strback'], |
||
| 283 | ]; |
||
| 284 | } |
||
| 285 | |||
| 286 | // Edit |
||
| 287 | $navlinks['alter'] = [ |
||
| 288 | 'attr' => [ |
||
| 289 | 'href' => [ |
||
| 290 | 'url' => 'database.php', |
||
| 291 | 'urlvars' => array_merge($fields, [ |
||
|
1 ignored issue
–
show
|
|||
| 292 | 'action' => 'sql', |
||
| 293 | ]), |
||
|
1 ignored issue
–
show
|
|||
| 294 | ], |
||
| 295 | ], |
||
| 296 | 'content' => $lang['streditsql'], |
||
| 297 | ]; |
||
| 298 | |||
| 299 | // Create view and download |
||
| 300 | if ('' !== $this->query && isset($rs) && is_object($rs) && $rs->recordCount() > 0) { |
||
| 301 | // Report views don't set a schema, so we need to disable create view in that case |
||
| 302 | if (isset($_REQUEST['schema'])) { |
||
| 303 | $navlinks['createview'] = [ |
||
| 304 | 'attr' => [ |
||
| 305 | 'href' => [ |
||
| 306 | 'url' => 'views.php', |
||
| 307 | 'urlvars' => array_merge($fields, [ |
||
|
1 ignored issue
–
show
|
|||
| 308 | 'action' => 'create', |
||
| 309 | ]), |
||
|
1 ignored issue
–
show
|
|||
| 310 | ], |
||
| 311 | ], |
||
| 312 | 'content' => $lang['strcreateview'], |
||
| 313 | ]; |
||
| 314 | } |
||
| 315 | |||
| 316 | if (isset($_REQUEST['search_path'])) { |
||
| 317 | $fields['search_path'] = $_REQUEST['search_path']; |
||
| 318 | } |
||
| 319 | |||
| 320 | $navlinks['download'] = [ |
||
| 321 | 'attr' => [ |
||
| 322 | 'href' => [ |
||
| 323 | 'url' => 'dataexport.php', |
||
| 324 | 'urlvars' => $fields, |
||
| 325 | ], |
||
| 326 | ], |
||
| 327 | 'content' => $lang['strdownload'], |
||
| 328 | ]; |
||
| 329 | } |
||
| 330 | |||
| 331 | $this->printNavLinks($navlinks, 'sql-form', get_defined_vars()); |
||
| 332 | |||
| 333 | return $this->printFooter($doBody, $template); |
||
| 334 | } |
||
| 336 |