Example #1
0
 public function testConstructWithDoubleTypeConvertsNonFloatToFloat()
 {
     $value = new Value('0.50', Value::TYPE_DOUBLE);
     $this->assertSame(0.5, $value->getValue());
 }
Example #2
0
 /**
  * Gets the struct value from the provided value DOM element
  * @param DOMElement $element The DOM element of the value
  * @return array
  * @throws zibo\library\xmlrpc\exception\XmlRpcException when one of the child member elements does not contain a name or value
  */
 private function parseStructElement(DOMElement $element)
 {
     $memberElements = $element->childNodes;
     $result = array();
     foreach ($memberElements as $memberElement) {
         $nameElement = $memberElement->getElementsByTagName('name')->item(0);
         if (!$nameElement) {
             throw new XmlRpcException('Invalid member value, no name found');
         }
         $valueElement = $memberElement->getElementsByTagName('value')->item(0);
         if (!$valueElement) {
             throw new XmlRpcException('Invalid member value, no value found');
         }
         $parameter = new Value($valueElement);
         $result[$nameElement->textContent] = $parameter->getValue();
     }
     return $result;
 }
Example #3
0
 /**
  * Parses a error response DOM element into this object
  * @param DOMElement $responseElement The response element
  * @return null
  * @throws zibo\library\xmlrpc\exception\XmlRpcException when the provided element is not a valid response element
  */
 private function parseFaultElement(DOMElement $responseElement)
 {
     $faultElement = $responseElement->getElementsByTagname('fault')->item(0);
     $valueElement = $faultElement->getElementsByTagName('value')->item(0);
     if (!$valueElement) {
         throw new XmlRpcException('Invalid fault response, fault tag has no value');
     }
     $valueObject = new Value($valueElement);
     $value = $valueObject->getValue();
     $this->errorCode = $value['faultCode'];
     $this->errorMessage = $value['faultString'];
 }