1: <?php
2: /**
3: * An XMLRPC call
4: *
5: * @package Elgg.Core
6: * @subpackage XMLRPC
7: */
8: class XMLRPCCall {
9: /** Method name */
10: private $methodname;
11:
12: /** Parameters */
13: private $params;
14:
15: /**
16: * Construct a new XML RPC Call
17: *
18: * @param string $xml XML
19: */
20: function __construct($xml) {
21: $this->parse($xml);
22: }
23:
24: /**
25: * Return the method name associated with the call.
26: *
27: * @return string
28: */
29: public function getMethodName() { return $this->methodname; }
30:
31: /**
32: * Return the parameters.
33: * Returns a nested array of XmlElement.
34: *
35: * @see XmlElement
36: * @return array
37: */
38: public function getParameters() { return $this->params; }
39:
40: /**
41: * Parse the xml into its components according to spec.
42: * This first version is a little primitive.
43: *
44: * @param string $xml XML
45: *
46: * @return void
47: */
48: private function parse($xml) {
49: $xml = xml_to_object($xml);
50:
51: // sanity check
52: if ((isset($xml->name)) && (strcasecmp($xml->name, "methodCall") != 0)) {
53: throw new CallException(elgg_echo('CallException:NotRPCCall'));
54: }
55:
56: // method name
57: $this->methodname = $xml->children[0]->content;
58:
59: // parameters
60: $this->params = $xml->children[1]->children;
61: }
62: }
63: