[Seriliazer] [XmlEncoder] Optimize conditions

This commit is contained in:
Joel Wurtz 2011-04-27 08:00:31 -07:00
parent b6a9935314
commit f11cc2de0b
1 changed files with 4 additions and 3 deletions

View File

@ -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;