Conditions | 21 |
Paths | 780 |
Total Lines | 57 |
Code Lines | 47 |
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 |
||
176 | function getDepFilesHTML($manifestroot, $fname, &$filenames, &$dcx, $folder) |
||
177 | { |
||
178 | $dcx->resetXpath(); |
||
179 | $nlist = $dcx->nodeList("//img/@src | //link/@href | //script/@src | //a[not(starts-with(@href,'#'))]/@href"); |
||
180 | $cssObjArray = []; |
||
181 | foreach ($nlist as $nl) { |
||
182 | $item = $folder.$nl->nodeValue; |
||
183 | $path_parts = pathinfo($item); |
||
184 | $fname = $path_parts['basename']; |
||
185 | $ext = array_key_exists('extension', $path_parts) ? $path_parts['extension'] : ''; |
||
186 | if (!isUrl($folder.$nl->nodeValue) && !isUrl($nl->nodeValue)) { |
||
187 | $path = $folder.$nl->nodeValue; |
||
188 | $file = fullPath($path, "/"); |
||
189 | toNativePath($file); |
||
190 | if (file_exists($manifestroot.DIRECTORY_SEPARATOR.$file)) { |
||
191 | $filenames[$file] = $file; |
||
192 | } |
||
193 | } |
||
194 | if ($ext == 'css') { |
||
195 | $css = new CssParser(); |
||
196 | $css->parse($dcx->filePath().$nl->nodeValue); |
||
197 | $cssObjArray[$item] = $css; |
||
198 | } |
||
199 | } |
||
200 | $nlist = $dcx->nodeList("//*/@class"); |
||
201 | foreach ($nlist as $nl) { |
||
202 | $item = $folder.$nl->nodeValue; |
||
203 | foreach ($cssObjArray as $csskey => $cssobj) { |
||
204 | $bimg = $cssobj->get($item, "background-image"); |
||
205 | $limg = $cssobj->get($item, "list-style-image"); |
||
206 | $npath = pathinfo($csskey); |
||
207 | if ((!empty($bimg)) && ($bimg != 'none')) { |
||
208 | $value = stripUrl($bimg, $npath['dirname'].'/'); |
||
209 | $filenames[$value] = $value; |
||
210 | } elseif ((!empty($limg)) && ($limg != 'none')) { |
||
211 | $value = stripUrl($limg, $npath['dirname'].'/'); |
||
212 | $filenames[$value] = $value; |
||
213 | } |
||
214 | } |
||
215 | } |
||
216 | $elemsToCheck = ["body", "p", "ul", "h4", "a", "th"]; |
||
217 | $doWeHaveIt = []; |
||
218 | foreach ($elemsToCheck as $elem) { |
||
219 | $doWeHaveIt[$elem] = ($dcx->nodeList("//".$elem)->length > 0); |
||
220 | } |
||
221 | foreach ($elemsToCheck as $elem) { |
||
222 | if ($doWeHaveIt[$elem]) { |
||
223 | foreach ($cssObjArray as $csskey => $cssobj) { |
||
224 | $sb = $cssobj->get($elem, "background-image"); |
||
225 | $sbl = $cssobj->get($elem, "list-style-image"); |
||
226 | $npath = pathinfo($csskey); |
||
227 | if ((!empty($sb)) && ($sb != 'none')) { |
||
228 | $value = stripUrl($sb, $npath['dirname'].'/'); |
||
229 | $filenames[$value] = $value; |
||
230 | } elseif ((!empty($sbl)) && ($sbl != 'none')) { |
||
231 | $value = stripUrl($sbl, $npath['dirname'].'/'); |
||
232 | $filenames[$value] = $value; |
||
233 | } |
||
238 |
If the returned type also contains false, it is an indicator that maybe an error condition leading to the specific return statement remains unhandled.