Conditions | 14 |
Paths | 126 |
Total Lines | 44 |
Code Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
54 | public function renderImagesHelper($images_arr, $links, $caption) |
||
55 | { |
||
56 | $linksArr = explode(',', $links); |
||
57 | $lines = array(); |
||
58 | $imageExists = false; |
||
59 | |||
60 | foreach ($images_arr as $k => $file) { |
||
61 | if (strlen(trim($file)) > 0) { |
||
62 | $lines[] = $file; |
||
63 | if ($links && count($linksArr) > 1) { |
||
64 | if (isset($linksArr[$k])) { |
||
65 | $ll = $linksArr[$k]; |
||
66 | } else { |
||
67 | $ll = $linksArr[0]; |
||
68 | } |
||
69 | |||
70 | $theLink = $this->getLink($ll); |
||
71 | if ($theLink) { |
||
72 | $lines[] = $this->configuration['images.']['linkPrefix'] . $theLink; |
||
73 | } |
||
74 | } |
||
75 | $imageExists = true; |
||
76 | } |
||
77 | } |
||
78 | if ($this->configuration['images.']['header'] && $imageExists) { |
||
79 | array_unshift($lines, $this->configuration['images.']['header']); |
||
80 | } |
||
81 | if ($links && count($linksArr) == 1) { |
||
82 | $theLink = $this->getLink($links); |
||
83 | if ($theLink) { |
||
84 | $lines[] = $this->configuration['images.']['linkPrefix'] . $theLink; |
||
85 | } |
||
86 | } |
||
87 | if ($caption) { |
||
88 | $lines[] = ''; |
||
89 | $cHeader = trim($this->configuration['images.']['captionHeader']); |
||
90 | if ($cHeader) { |
||
91 | $lines[] = $cHeader; |
||
92 | } |
||
93 | $lines[] = $this->breakContent($caption); |
||
94 | } |
||
95 | |||
96 | return chr(10) . implode(chr(10), $lines); |
||
97 | } |
||
98 | } |
||
99 |