Ver Fonte

[Seriliazer] [XmlEncoder] Optimize conditions

Joel Wurtz há 14 anos atrás
pai
commit
f11cc2de0b
1 ficheiros alterados com 4 adições e 3 exclusões
  1. 4 3
      src/Symfony/Component/Serializer/Encoder/XmlEncoder.php

+ 4 - 3
src/Symfony/Component/Serializer/Encoder/XmlEncoder.php

@@ -54,9 +54,10 @@ class XmlEncoder extends AbstractEncoder implements DecoderInterface
     public function decode($data, $format)
     {
         $xml = simplexml_load_string($data);
-        if (!$xml->count() && !$xml->attributes()) {
-            return (string) $xml;
-        } elseif (!$xml->count()) {
+        if (!$xml->count()) {
+            if (!$xml->attributes()) {
+                return (string) $xml;
+            }
             $data = array();
             foreach ($xml->attributes() as $attrkey => $attr) {
                 $data['@'.$attrkey] = (string) $attr;