|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00034 class Zend_Service_Nirvanix_Response 00035 { 00041 protected $_sxml; 00042 00050 public function __construct($xml) 00051 { 00052 $this->_sxml = @simplexml_load_string($xml); 00053 00054 if (! $this->_sxml instanceof SimpleXMLElement) { 00055 $this->_throwException("XML could not be parsed from response: $xml"); 00056 } 00057 00058 $name = $this->_sxml->getName(); 00059 if ($name != 'Response') { 00060 $this->_throwException("Expected XML element Response, got $name"); 00061 } 00062 00063 $code = (int)$this->_sxml->ResponseCode; 00064 if ($code != 0) { 00065 $msg = (string)$this->_sxml->ErrorMessage; 00066 $this->_throwException($msg, $code); 00067 } 00068 } 00069 00076 public function getSxml() 00077 { 00078 return $this->_sxml; 00079 } 00080 00087 public function __get($offset) 00088 { 00089 return $this->_sxml->$offset; 00090 } 00091 00099 public function __call($method, $args) 00100 { 00101 return call_user_func_array(array($this->_sxml, $method), $args); 00102 } 00103 00113 protected function _throwException($message, $code = null) 00114 { 00118 require_once 'Zend/Service/Nirvanix/Exception.php'; 00119 00120 throw new Zend_Service_Nirvanix_Exception($message, $code); 00121 } 00122 00123 }