/** * This method parses a child node. * * @access protected * @param \SimpleXMLElement $node a reference to a child node * @return \Unicity\Common\Mutable\ICollection a collection representing the data * in the soap file * @throws \Unicity\Throwable\Parse\Exception indicates that an unrecognized child * node was encountered */ protected function parseChildElement(\SimpleXMLElement $node) { $children = $node->children(); if (count($children) > 0) { $list = new Common\Mutable\ArrayList(); $map = new Common\Mutable\HashMap(); foreach ($children as $child) { $name = $child->getName(); $value = $this->parseChildElement($child); $temp = new Common\Mutable\HashMap(); $temp->putEntry($name, $value); $list->addValue($temp); $map->putEntry($name, $value); } return $list->count() > $map->count() || $this->directives->hasKey('expandableProperties') && $this->directives->getValue('expandableProperties')->hasValue($node->getName()) ? $list : $map; } else { $value = dom_import_simplexml($node)->textContent; $value = trim($value); if ($value == '') { $value = Core\Data\Undefined::instance(); } else { if (preg_match('/^(true|false)$/i', $value)) { $value = Core\Convert::toBoolean($value); } else { if (preg_match('/^[+-]?(0|[1-9][0-9]*)((\\.[0-9]+)|([eE][+-]?(0|[1-9][0-9]*)))$/', $value)) { $value = Core\Convert::toDouble($value); } else { if (filter_var($value, FILTER_VALIDATE_INT) !== false) { $value = Core\Convert::toInteger($value); } else { $value = Core\Convert::toString($value); } } } } return $value; } }
/** * This method parses a custom node. * * @access protected * @param \SimpleXMLElement $node a reference to a custom node * @return \Unicity\Common\Mutable\ICollection a collection representing the data * in the soap file * @throws \Unicity\Throwable\Parse\Exception indicates that an unrecognized child * node was encountered */ protected function parseCustomElement(\SimpleXMLElement $node) { $children = $this->getElementChildren($node, null); if (count($children) > 0) { $list = new Common\Mutable\ArrayList(); $map = new Common\Mutable\HashMap(); foreach ($children as $child) { $name = $child->getName(); $value = $this->parseCustomElement($child); $temp = new Common\Mutable\HashMap(); $temp->putEntry($name, $value); $list->addValue($temp); $map->putEntry($name, $value); } return $list->count() > $map->count() || $this->directives->hasKey('expandableProperties') && $this->directives->getValue('expandableProperties')->hasValue($node->getName()) ? $list : $map; } else { $value = dom_import_simplexml($node)->textContent; $value = trim($value); if ($value == '') { $attributes = $node->attributes('xsi', true); if (isset($attributes['nil'])) { $nil = SOAP\Data\XML::valueOf($attributes['nil']); if (!SOAP\Data\XML\Syntax::isBoolean($nil)) { throw new Throwable\Parse\Exception('Unable to process SOAP XML. Expected a valid boolean token, but got ":token".', array(':token' => $nil)); } $value = strtolower($nil) != 'false' ? null : Core\Data\Undefined::instance(); } else { $value = Core\Data\Undefined::instance(); } } else { if (preg_match('/^(true|false)$/i', $value)) { $value = Core\Convert::toBoolean($value); } else { if (preg_match('/^[+-]?(0|[1-9][0-9]*)((\\.[0-9]+)|([eE][+-]?(0|[1-9][0-9]*)))$/', $value)) { $value = Core\Convert::toDouble($value); } else { if (filter_var($value, FILTER_VALIDATE_INT) !== false) { $value = Core\Convert::toInteger($value); } else { $value = Core\Convert::toString($value); } } } } return $value; } }