| Conditions | 5 |
| Paths | 5 |
| Total Lines | 59 |
| Code Lines | 38 |
| 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 |
||
| 104 | public static function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection) |
||
|
1 ignored issue
–
show
|
|||
| 105 | { |
||
| 106 | if (error_reporting() == 0) { |
||
| 107 | return; |
||
| 108 | } |
||
| 109 | |||
| 110 | $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); |
||
| 111 | |||
| 112 | $btarray0 = [ |
||
| 113 | 'msg' => 'ADOdbException at ', |
||
| 114 | 'class' => $backtrace[1]['class'], |
||
| 115 | 'type' => $backtrace[1]['type'], |
||
| 116 | 'function' => $backtrace[1]['function'], |
||
| 117 | 'spacer' => ' ', |
||
| 118 | 'line' => $backtrace[0]['line'], |
||
| 119 | ]; |
||
| 120 | |||
| 121 | $errmsg = htmlentities(\PHPPgAdmin\Traits\HelperTrait::br2ln($errmsg), ENT_NOQUOTES); |
||
| 122 | $p1 = htmlentities(\PHPPgAdmin\Traits\HelperTrait::br2ln($p1), ENT_NOQUOTES); |
||
| 123 | $p2 = htmlentities(\PHPPgAdmin\Traits\HelperTrait::br2ln($p2), ENT_NOQUOTES); |
||
| 124 | |||
| 125 | switch ($fn) { |
||
| 126 | case 'EXECUTE': |
||
| 127 | $sql = str_replace( |
||
| 128 | [ |
||
| 129 | 'SELECT', |
||
| 130 | 'WHERE', |
||
| 131 | 'GROUP BY', |
||
| 132 | 'FROM', |
||
| 133 | 'HAVING', |
||
| 134 | 'LIMIT', |
||
| 135 | ], |
||
| 136 | ["\nSELECT", "\nWHERE", "\nGROUP BY", "\nFROM", "\nHAVING", "\nLIMIT"], |
||
| 137 | $p1 |
||
| 138 | ); |
||
| 139 | |||
| 140 | $inputparams = $p2; |
||
| 141 | |||
| 142 | $error_msg = '<p><b>strsqlerror</b><br />' . nl2br($errmsg) . '</p> <p><b>SQL:</b><br />' . nl2br($sql) . '</p> '; |
||
| 143 | |||
| 144 | echo '<table class="error" cellpadding="5"><tr><td>' . nl2br($error_msg) . '</td></tr></table><br />' . "\n"; |
||
| 145 | |||
| 146 | break; |
||
| 147 | case 'PCONNECT': |
||
| 148 | case 'CONNECT': |
||
| 149 | // do nothing; |
||
| 150 | break; |
||
| 151 | default: |
||
| 152 | $s = "${dbms} error: [${errno}: ${errmsg}] in ${fn}(${p1}, ${p2})\n"; |
||
| 153 | echo "<table class=\"error\" cellpadding=\"5\"><tr><td>{$s}</td></tr></table><br />\n"; |
||
| 154 | |||
| 155 | break; |
||
| 156 | } |
||
| 157 | |||
| 158 | $tag = implode('', $btarray0); |
||
| 159 | |||
| 160 | \PC::debug(['errno' => $errno, 'fn' => $fn, 'errmsg' => $errmsg], $tag); |
||
| 161 | |||
| 162 | throw new \PHPPgAdmin\ADOdbException($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection); |
||
| 163 | } |
||
| 165 |