- $enclosures = $xpath->query("enclosure|atom:link[@rel='enclosure']", $entry);
- foreach ($enclosures as $enclosure) {
- $href = '';
- $length = null;
- $type = null;
-
- foreach ($enclosure->attributes as $attribute) {
- if (in_array($attribute->name, ['url', 'href'])) {
- $href = $attribute->textContent;
- } elseif ($attribute->name == 'length') {
- $length = (int)$attribute->textContent;
- } elseif ($attribute->name == 'type') {
- $type = $attribute->textContent;
+ $enclosures = $xpath->query("enclosure|$atomns:link[@rel='enclosure']", $entry);
+ if (!empty($enclosures)) {
+ foreach ($enclosures as $enclosure) {
+ $href = '';
+ $length = null;
+ $type = null;
+
+ foreach ($enclosure->attributes as $attribute) {
+ if (in_array($attribute->name, ['url', 'href'])) {
+ $href = $attribute->textContent;
+ } elseif ($attribute->name == 'length') {
+ $length = (int)$attribute->textContent;
+ } elseif ($attribute->name == 'type') {
+ $type = $attribute->textContent;
+ }