Conditions | 6 |
Paths | 9 |
Total Lines | 66 |
Code Lines | 36 |
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 |
||
161 | protected function render_params() : string |
||
162 | { |
||
163 | $params = $this->info->getParams(); |
||
164 | |||
165 | if(empty($params)) { |
||
166 | return ''; |
||
167 | } |
||
168 | |||
169 | $tokens = array(); |
||
170 | $excluded = array(); |
||
171 | |||
172 | if($this->info->isParamExclusionEnabled()) |
||
173 | { |
||
174 | $excluded = $this->info->getExcludedParams(); |
||
175 | } |
||
176 | |||
177 | foreach($params as $param => $value) |
||
178 | { |
||
179 | $parts = sprintf( |
||
180 | '<span class="link-param-name">%s</span>'. |
||
181 | '<span class="link-component param-equals">=</span>'. |
||
182 | '<span class="link-param-value">%s</span>'. |
||
183 | '<wbr>', |
||
184 | $param, |
||
185 | str_replace( |
||
186 | array(':', '.', '-', '_'), |
||
187 | array(':<wbr>', '.<wbr>', '-<wbr>', '_<wbr>'), |
||
188 | $value |
||
189 | ) |
||
190 | ); |
||
191 | |||
192 | $tag = ''; |
||
193 | |||
194 | // is parameter exclusion enabled, and is this an excluded parameter? |
||
195 | if(isset($excluded[$param])) |
||
196 | { |
||
197 | // display the excluded parameter, but highlight it |
||
198 | if($this->info->isHighlightExcludeEnabled()) |
||
199 | { |
||
200 | $tooltip = $excluded[$param]; |
||
201 | |||
202 | $tag = sprintf( |
||
203 | '<span class="link-param excluded-param" title="%s" data-toggle="tooltip">%s</span>', |
||
204 | $tooltip, |
||
205 | $parts |
||
206 | ); |
||
207 | } |
||
208 | else |
||
209 | { |
||
210 | continue; |
||
211 | } |
||
212 | } |
||
213 | else |
||
214 | { |
||
215 | $tag = sprintf( |
||
216 | '<span class="link-param">%s</span>', |
||
217 | $parts |
||
218 | ); |
||
219 | } |
||
220 | |||
221 | $tokens[] = $tag; |
||
222 | } |
||
223 | |||
224 | return |
||
225 | '<span class="link-component query-sign">?</span>'. |
||
226 | implode('<span class="link-component param-separator">&</span>', $tokens); |
||
227 | } |
||
242 |