Skip to content

Commit a3a5e3f

Browse files
committed
Version 3.1.2
Update domnodeToArray method.
1 parent 6af6171 commit a3a5e3f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/ResourceLink.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,20 +1297,21 @@ private function domnodeToArray($node)
12971297
$output[$child->tagName][] = $v;
12981298
} else {
12991299
$s = (string) $v;
1300-
if (strlen($s) > 0) {
1300+
if (!empty($s)) {
13011301
$output = $s;
1302-
break;
13031302
}
13041303
}
13051304
}
1306-
if ($node->hasAttributes()) {
1307-
foreach ($node->attributes as $attrNode) {
1308-
$output['@attributes'][$attrNode->name] = (string) $attrNode->value;
1305+
if (is_array($output)) {
1306+
if ($node->hasAttributes()) {
1307+
foreach ($node->attributes as $attrNode) {
1308+
$output['@attributes'][$attrNode->name] = (string) $attrNode->value;
1309+
}
13091310
}
1310-
}
1311-
foreach ($output as $t => $v) {
1312-
if (is_array($v) && count($v) == 1 && $t != '@attributes') {
1313-
$output[$t] = $v[0];
1311+
foreach ($output as $t => $v) {
1312+
if (is_array($v) && (count($v) === 1) && ($t !== '@attributes')) {
1313+
$output[$t] = $v[0];
1314+
}
13141315
}
13151316
}
13161317
break;

0 commit comments

Comments
 (0)