| Conditions | 8 |
| Paths | 17 |
| Total Lines | 76 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 90 | * @param array $backtraces |
||
| 91 | * @return string |
||
| 92 | */ |
||
| 93 | protected static function getBacktracesDump(array $backtraces) |
||
| 94 | { |
||
| 95 | $return = static::getStylesDump(); |
||
| 96 | $return .= static::getJavascriptDump(); |
||
| 97 | |||
| 98 | $return .= '<div class="steevanb-backtrace-container">'; |
||
| 99 | $return .= static::getCallerDump(); |
||
| 100 | |||
| 101 | $return .= ' |
||
| 102 | <table class="table-backtrace"> |
||
| 103 | <tr> |
||
| 104 | <th>#</th> |
||
| 105 | <th>File::Line</th> |
||
| 106 | <th>Call</th> |
||
| 107 | </tr> |
||
| 108 | '; |
||
| 109 | $previewPrefix = uniqid('steevanb_backtrace_preview'); |
||
| 110 | foreach ($backtraces as $index => $backtrace) { |
||
| 111 | $return .= static::getBacktraceDump($backtrace, $index, $previewPrefix); |
||
| 112 | } |
||
| 113 | $return .= '</table>'; |
||
| 114 | |||
| 115 | $return .= '</div>'; |
||
| 116 | |||
| 117 | return $return; |
||
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @return string |
||
| 122 | */ |
||
| 123 | protected static function getStylesDump() |
||
| 124 | { |
||
| 125 | return ' |
||
| 126 | <style type="text/css"> |
||
| 127 | .steevanb-backtrace-container { |
||
| 128 | padding: 5px; |
||
| 129 | border: solid 2px #9e9e9e; |
||
| 130 | background-color: #F5F5F5; |
||
| 131 | cursor: default; |
||
| 132 | font-family: monospace; |
||
| 133 | } |
||
| 134 | .steevanb-backtrace-container table { |
||
| 135 | border-collapse: collapse; |
||
| 136 | } |
||
| 137 | .steevanb-backtrace-container table.table-backtrace tr.dark { |
||
| 138 | background-color: #e5e5e5; |
||
| 139 | } |
||
| 140 | .steevanb-backtrace-container table.table-backtrace td { |
||
| 141 | padding: 2px !important; |
||
| 142 | } |
||
| 143 | .steevanb-backtrace-container table.table-backtrace td a, |
||
| 144 | .steevanb-backtrace-container table.table-backtrace td a:hover, |
||
| 145 | .steevanb-backtrace-container table.table-backtrace td a:visited |
||
| 146 | { |
||
| 147 | color: #4e7ca9 !important; |
||
| 148 | text-decoration: none !important; |
||
| 149 | cursor: pointer !important; |
||
| 150 | } |
||
| 151 | .steevanb-backtrace-container table.table-backtrace td a:hover { |
||
| 152 | text-decoration: underline !important; |
||
| 153 | } |
||
| 154 | </style>'; |
||
| 155 | } |
||
| 156 | |||
| 157 | /** |
||
| 158 | * @return string |
||
| 159 | */ |
||
| 160 | protected static function getJavascriptDump() |
||
| 161 | { |
||
| 162 | return ' |
||
| 163 | <script type="text/javascript"> |
||
| 164 | function steevanb_dev_showCodePreview(id) |
||
| 165 | { |
||
| 166 | var element = document.getElementById(id); |
||
| 293 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.