| Conditions | 12 |
| Paths | 72 |
| Total Lines | 69 |
| 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 |
||
| 118 | protected static function getBacktraceDump(array $backtrace, $index, $previewPrefix) |
||
| 119 | { |
||
| 120 | $filePath = null; |
||
| 121 | $line = null; |
||
| 122 | $previewId = $previewPrefix . '_' . $index; |
||
| 123 | |||
| 124 | if ($backtrace['file'] !== null) { |
||
| 125 | if (file_exists($backtrace['file'])) { |
||
| 126 | $filePath = $backtrace['file']; |
||
| 127 | $fileFound = true; |
||
| 128 | |||
| 129 | if ($backtrace['line'] !== null) { |
||
| 130 | $line = $backtrace['line']; |
||
| 131 | $lineFound = true; |
||
| 132 | } else { |
||
| 133 | $lineFound = false; |
||
| 134 | } |
||
| 135 | } elseif (substr($backtrace['file'], -16) === ' : eval()\'d code') { |
||
| 136 | $fileAndLine = substr($backtrace['file'], 0, -16); |
||
| 137 | $filePath = substr($fileAndLine, 0, strrpos($fileAndLine, '(')); |
||
| 138 | if (file_exists($filePath)) { |
||
| 139 | $line = substr($fileAndLine, strrpos($fileAndLine, '(') + 1, -1); |
||
| 140 | $fileFound = true; |
||
| 141 | $lineFound = true; |
||
| 142 | } else { |
||
| 143 | $fileFound = false; |
||
| 144 | $lineFound = false; |
||
| 145 | } |
||
| 146 | } else { |
||
| 147 | $fileFound = false; |
||
| 148 | $lineFound = false; |
||
| 149 | } |
||
| 150 | } else { |
||
| 151 | $fileFound = false; |
||
| 152 | $lineFound = false; |
||
| 153 | } |
||
| 154 | |||
| 155 | if ($fileFound === false && $lineFound === false) { |
||
| 156 | $fileLineHtml = '\Closure'; |
||
| 157 | $codePreview = null; |
||
| 158 | } else { |
||
| 159 | $codePreview = static::getCodePreview($filePath, $line); |
||
| 160 | $fileLineHtml = ' |
||
| 161 | <a |
||
| 162 | title="' . static::getFilePath($filePath) . '" |
||
| 163 | onclick="steevanb_dev_showCodePreview(\'' . $previewId . '\')" |
||
| 164 | > |
||
| 165 | ' . basename($filePath) . '#' . $line . ' |
||
| 166 | </a> |
||
| 167 | '; |
||
| 168 | } |
||
| 169 | |||
| 170 | $html = ' |
||
| 171 | <tr' . ($index % 2 ? null : ' class="dark"') . '> |
||
| 172 | <td>' . ($index + 1) . '</td> |
||
| 173 | <td>' . $fileLineHtml . '</td> |
||
| 174 | <td>' . $backtrace['call'] . '</td> |
||
| 175 | </tr> |
||
| 176 | '; |
||
| 177 | if ($fileFound && $lineFound) { |
||
| 178 | $html .= ' |
||
| 179 | <tr' . ($index % 2 ? null : ' class="dark"') . ' id="' . $previewId . '" style="display: none"> |
||
| 180 | <td colspan="3"><pre>' . $codePreview . '</pre></td> |
||
| 181 | </tr> |
||
| 182 | '; |
||
| 183 | } |
||
| 184 | |||
| 185 | return $html; |
||
| 186 | } |
||
| 187 | |||
| 232 |