[Seriliazer] [XmlEncoder] Optimize conditions

This commit is contained in:
Joel Wurtz 2011-04-27 08:00:31 -07:00
parent b6a9935314
commit f11cc2de0b

View File

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