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