[Pull Request 3134] Improved code based on comments
This commit is contained in:
parent
90abc0f454
commit
7f3464386b
@ -304,21 +304,18 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
|
|||||||
return $appendNode;
|
return $appendNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a value contains any characters which would require CDATA padding.
|
* Checks if a value contains any characters which would require CDATA wrapping.
|
||||||
*
|
*
|
||||||
* @param string $val
|
* @param string $val
|
||||||
*
|
*
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
private function needsCdataPadding($val)
|
private function needsCdataWrapping($val)
|
||||||
{
|
{
|
||||||
return preg_match('/[<>&]/', $val);
|
return preg_match('/[<>&]/', $val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the value being passed and decide what sort of element to create
|
* Tests the value being passed and decide what sort of element to create
|
||||||
*
|
*
|
||||||
@ -340,7 +337,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
|
|||||||
return $this->buildXml($node, $this->serializer->normalize($val, $this->format));
|
return $this->buildXml($node, $this->serializer->normalize($val, $this->format));
|
||||||
} elseif (is_numeric($val)) {
|
} elseif (is_numeric($val)) {
|
||||||
return $this->appendText($node, (string) $val);
|
return $this->appendText($node, (string) $val);
|
||||||
} elseif (is_string($val) && $this->needsCdataPadding($val)) {
|
} elseif (is_string($val) && $this->needsCdataWrapping($val)) {
|
||||||
return $this->appendCData($node, $val);
|
return $this->appendCData($node, $val);
|
||||||
} elseif (is_string($val)) {
|
} elseif (is_string($val)) {
|
||||||
return $this->appendText($node, $val);
|
return $this->appendText($node, $val);
|
||||||
|
Reference in New Issue
Block a user