mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-26 11:05:28 +01:00
Breaking XML attribute parsing into its own method
This commit is contained in:
parent
1ec658b251
commit
71d631680f
@ -117,13 +117,7 @@ class XmlVisitor extends AbstractResponseVisitor
|
||||
$name = $property->getName();
|
||||
$sentAs = $property->getWireName();
|
||||
if ($property->getData('xmlAttribute')) {
|
||||
if (isset($value['@attributes'][$sentAs])) {
|
||||
$value[$name] = $value['@attributes'][$sentAs];
|
||||
unset($value['@attributes'][$sentAs]);
|
||||
if (empty($value['@attributes'])) {
|
||||
unset($value['@attributes']);
|
||||
}
|
||||
}
|
||||
$this->processXmlAttribute($property, $value);
|
||||
} elseif (isset($value[$sentAs])) {
|
||||
$this->recursiveProcess($property, $value[$sentAs]);
|
||||
if ($name != $sentAs) {
|
||||
@ -137,4 +131,22 @@ class XmlVisitor extends AbstractResponseVisitor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process an XML attribute property
|
||||
*
|
||||
* @param Parameter $property Property to process
|
||||
* @param array $value Value to process and update
|
||||
*/
|
||||
protected function processXmlAttribute(Parameter $property, array &$value)
|
||||
{
|
||||
$sentAs = $property->getWireName();
|
||||
if (isset($value['@attributes'][$sentAs])) {
|
||||
$value[$property->getName()] = $value['@attributes'][$sentAs];
|
||||
unset($value['@attributes'][$sentAs]);
|
||||
if (empty($value['@attributes'])) {
|
||||
unset($value['@attributes']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user