/**
  * Convert data from array to Data Object representation if type is Data Object or array of Data Objects.
  *
  * @param mixed $value
  * @param string $type Convert given value to the this type
  * @return mixed
  */
 protected function _convertValue($value, $type)
 {
     $isArrayType = $this->_typeProcessor->isArrayType($type);
     if ($isArrayType && isset($value['item'])) {
         $value = $this->_removeSoapItemNode($value);
     }
     if ($this->_typeProcessor->isTypeSimple($type) || $this->_typeProcessor->isTypeAny($type)) {
         $result = $this->_typeProcessor->processSimpleAndAnyType($value, $type);
     } else {
         /** Complex type or array of complex types */
         if ($isArrayType) {
             // Initializing the result for array type else it will return null for empty array
             $result = is_array($value) ? [] : null;
             $itemType = $this->_typeProcessor->getArrayItemType($type);
             if (is_array($value)) {
                 foreach ($value as $key => $item) {
                     $result[$key] = $this->_createFromArray($itemType, $item);
                 }
             }
         } else {
             $result = $this->_createFromArray($type, $value);
         }
     }
     return $result;
 }
 /**
  * Process different element types.
  *
  * @param string $elementType
  * @param string $documentation
  * @param \DOMElement $appInfoNode
  * @return void
  */
 protected function _processElementType($elementType, $documentation, \DOMElement $appInfoNode)
 {
     if ($elementType == 'int') {
         $this->_processRequiredAnnotation('min', $documentation, $appInfoNode);
         $this->_processRequiredAnnotation('max', $documentation, $appInfoNode);
     }
     if ($elementType == 'string') {
         $this->_processRequiredAnnotation('maxLength', $documentation, $appInfoNode);
     }
     if ($this->_typeProcessor->isArrayType($elementType)) {
         $natureOfTypeNode = $this->_getDom()->createElement(self::APP_INF_NS . ':natureOfType');
         $natureOfTypeNode->appendChild($this->_getDom()->createTextNode('array'));
         $appInfoNode->appendChild($natureOfTypeNode);
     }
 }
Esempio n. 3
0
 public function testIsArrayType()
 {
     $this->assertFalse($this->_typeProcessor->isArrayType('string'));
     $this->assertTrue($this->_typeProcessor->isArrayType('string[]'));
 }