/** * Converts an XML_RPC_Value object into native PHP types * * @param XML_RPC_Value $XML_RPC_val the object to decode * @return mixed the PHP values * @throws InvalidArgumentException */ public static function decode($XML_RPC_val) { $kind = $XML_RPC_val->kindOf(); if ($kind === 'scalar') { return $XML_RPC_val->scalarValue(); } elseif ($kind == 'array') { $size = $XML_RPC_val->arraySize(); $arr = array(); for ($i = 0; $i < $size; $i++) { $arr[] = self::decode($XML_RPC_val->arrayMem($i)); } return $arr; } elseif ($kind === 'struct') { $XML_RPC_val->structReset(); $arr = array(); while (list($key, $value) = $XML_RPC_val->structEach()) { $arr[$key] = self::decode($value); } return $arr; } throw new InvalidArgumentException(__METHOD__ . ': Unknown value type ' . $kind); }