43 require_once
'XML/RPC2/Exception.php';
44 require_once
'XML/RPC2/Value.php';
91 $this->_nativeValue = $value;
125 if (is_null($explicitType)) {
126 switch (gettype($nativeValue)) {
128 $explicitType =
'boolean';
131 $explicitType =
'int';
134 $explicitType =
'double';
137 $explicitType =
'string';
140 $explicitType =
'array';
141 $keys = array_keys($nativeValue);
142 if (count($keys) > 0) {
143 if ($keys[0] !== 0 && ($keys[0] !== 1)) $explicitType =
'struct';
146 $previous = $keys[$i];
148 if (array_key_exists($i, $keys) && ($keys[$i] !== $keys[$i - 1] + 1)) $explicitType =
'struct';
149 }
while (array_key_exists($i, $keys) && $explicitType ==
'array');
153 if ((strtolower(get_class($nativeValue)) ==
'stdclass') && (isset($nativeValue->xmlrpc_type))) {
156 $explicitType = $nativeValue->xmlrpc_type;
158 $nativeValue = serialize($nativeValue);
159 $explicitType =
'base64';
166 (
string) $nativeValue,
167 gettype($nativeValue)));
170 gettype($nativeValue),
171 (
string) $nativeValue));
174 $explicitType = ucfirst(strtolower($explicitType));
175 switch ($explicitType) {
181 require_once
'XML/RPC2/Backend/Php/Value/Scalar.php';
184 case 'Datetime.iso8601':
186 require_once
'XML/RPC2/Backend/Php/Value/Datetime.php';
190 require_once
'XML/RPC2/Backend/Php/Value/Base64.php';
194 require_once
'XML/RPC2/Backend/Php/Value/Array.php';
198 require_once
'XML/RPC2/Backend/Php/Value/Struct.php';
219 $simpleXML = simplexml_load_string($simpleXML->asXML());
221 $valueType = $simpleXML->xpath(
'./*');
222 if (count($valueType) == 1) {
223 $nodename = dom_import_simplexml($valueType[0])->nodeName;
227 $nativeType =
'Integer';
230 $nativeType =
'Boolean';
233 $nativeType =
'Double';
236 $nativeType =
'String';
238 case 'dateTime.iso8601':
239 $nativeType =
'Datetime';
242 $nativeType =
'Base64';
245 $nativeType =
'Array';
248 $nativeType =
'Struct';
251 throw new XML_RPC2_DecodeException(sprintf(
'Unable to decode XML-RPC value. Value type is not recognized \'%s\'', $nodename));
253 } elseif (count($valueType) == 0) {
255 $nativeType =
'String';
257 throw new XML_RPC2_DecodeException(sprintf(
'Unable to decode XML-RPC value. Value presented %s type nodes: %s.', count($valueType), $simpleXML->asXML()));
259 require_once(sprintf(
'XML/RPC2/Backend/Php/Value/%s.php', $nativeType));
260 $nativeType =
'XML_RPC2_Backend_Php_Value_' . $nativeType;