Conditions | 10 |
Paths | 128 |
Total Lines | 33 |
Code Lines | 19 |
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 |
||
23 | protected static function attrToSyntax($attrs) { |
||
24 | $prefix = '{{rss>'; |
||
25 | $url = ''; |
||
26 | if (!empty($attrs['url'])) { |
||
27 | $url = $attrs['url']; |
||
28 | } |
||
29 | $paramString = ''; |
||
30 | |||
31 | if (!empty($attrs['max']) && $attrs['max'] !== 8) { |
||
32 | $paramString .= ' ' . $attrs['max']; |
||
33 | } |
||
34 | |||
35 | if (!empty($attrs['reverse'])) { |
||
36 | $paramString .= ' reverse'; |
||
37 | } |
||
38 | |||
39 | if (!empty($attrs['author'])) { |
||
40 | $paramString .= ' author'; |
||
41 | } |
||
42 | |||
43 | if (!empty($attrs['date'])) { |
||
44 | $paramString .= ' date'; |
||
45 | } |
||
46 | |||
47 | if (!empty($attrs['details'])) { |
||
48 | $paramString .= ' description'; |
||
49 | } |
||
50 | |||
51 | if (!empty($attrs['refresh']) && $attrs['refresh'] !== '4h') { |
||
52 | $paramString .= ' ' . $attrs['refresh']; |
||
53 | } |
||
54 | $postfix = '}}'; |
||
55 | return $prefix . $url . $paramString . $postfix; |
||
56 | } |
||
65 |