| Conditions | 12 |
| Paths | 80 |
| Total Lines | 74 |
| Code Lines | 46 |
| 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 |
||
| 89 | public function get_enclosures() { |
||
| 90 | $encs = []; |
||
| 91 | |||
| 92 | $enclosures = $this->xpath->query("media:content", $this->elem); |
||
| 93 | |||
| 94 | foreach ($enclosures as $enclosure) { |
||
| 95 | $enc = new FeedEnclosure(); |
||
| 96 | |||
| 97 | $enc->type = clean($enclosure->getAttribute("type")); |
||
| 98 | $enc->link = clean($enclosure->getAttribute("url")); |
||
| 99 | $enc->length = clean($enclosure->getAttribute("length")); |
||
| 100 | $enc->height = clean($enclosure->getAttribute("height")); |
||
| 101 | $enc->width = clean($enclosure->getAttribute("width")); |
||
| 102 | |||
| 103 | $medium = clean($enclosure->getAttribute("medium")); |
||
| 104 | if (!$enc->type && $medium) { |
||
| 105 | $enc->type = strtolower("$medium/generic"); |
||
| 106 | } |
||
| 107 | |||
| 108 | $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
||
| 109 | if ($desc) { |
||
| 110 | $enc->title = clean($desc->nodeValue); |
||
| 111 | } |
||
| 112 | |||
| 113 | array_push($encs, $enc); |
||
| 114 | } |
||
| 115 | |||
| 116 | $enclosures = $this->xpath->query("media:group", $this->elem); |
||
| 117 | |||
| 118 | foreach ($enclosures as $enclosure) { |
||
| 119 | $enc = new FeedEnclosure(); |
||
| 120 | |||
| 121 | $content = $this->xpath->query("media:content", $enclosure)->item(0); |
||
| 122 | |||
| 123 | if ($content) { |
||
| 124 | $enc->type = clean($content->getAttribute("type")); |
||
| 125 | $enc->link = clean($content->getAttribute("url")); |
||
| 126 | $enc->length = clean($content->getAttribute("length")); |
||
| 127 | $enc->height = clean($content->getAttribute("height")); |
||
| 128 | $enc->width = clean($content->getAttribute("width")); |
||
| 129 | |||
| 130 | $medium = clean($content->getAttribute("medium")); |
||
| 131 | if (!$enc->type && $medium) { |
||
| 132 | $enc->type = strtolower("$medium/generic"); |
||
| 133 | } |
||
| 134 | |||
| 135 | $desc = $this->xpath->query("media:description", $content)->item(0); |
||
| 136 | if ($desc) { |
||
| 137 | $enc->title = clean($desc->nodeValue); |
||
| 138 | } else { |
||
| 139 | $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
||
| 140 | if ($desc) { |
||
| 141 | $enc->title = clean($desc->nodeValue); |
||
| 142 | } |
||
| 143 | } |
||
| 144 | |||
| 145 | array_push($encs, $enc); |
||
| 146 | } |
||
| 147 | } |
||
| 148 | |||
| 149 | $enclosures = $this->xpath->query("media:thumbnail", $this->elem); |
||
| 150 | |||
| 151 | foreach ($enclosures as $enclosure) { |
||
| 152 | $enc = new FeedEnclosure(); |
||
| 153 | |||
| 154 | $enc->type = "image/generic"; |
||
| 155 | $enc->link = clean($enclosure->getAttribute("url")); |
||
| 156 | $enc->height = clean($enclosure->getAttribute("height")); |
||
| 157 | $enc->width = clean($enclosure->getAttribute("width")); |
||
| 158 | |||
| 159 | array_push($encs, $enc); |
||
| 160 | } |
||
| 161 | |||
| 162 | return $encs; |
||
| 163 | } |
||
| 211 |