Example #1
0
 /**
  * Parses the current XML element.
  *
  * This method returns arn array with 3 properties:
  *   * name - A clark-notation XML element name.
  *   * value - The parsed value.
  *   * attributes - A key-value list of attributes.
  *
  * @return array
  */
 function parseCurrentElement()
 {
     $name = $this->getClark();
     $attributes = [];
     if ($this->hasAttributes) {
         $attributes = $this->parseAttributes();
     }
     if (array_key_exists($name, $this->elementMap)) {
         $deserializer = $this->elementMap[$name];
         if (is_subclass_of($deserializer, 'Sabre\\Xml\\XmlDeserializable')) {
             $value = call_user_func([$deserializer, 'xmlDeserialize'], $this);
         } elseif (is_callable($deserializer)) {
             $value = call_user_func($deserializer, $this);
         } else {
             $type = gettype($deserializer);
             if ($type === 'string') {
                 $type .= ' (' . $deserializer . ')';
             } elseif ($type === 'object') {
                 $type .= ' (' . get_class($deserializer) . ')';
             }
             throw new \LogicException('Could not use this type as a deserializer: ' . $type);
         }
     } else {
         $value = Element\Base::xmlDeserialize($this);
     }
     return ['name' => $name, 'value' => $value, 'attributes' => $attributes];
 }
Example #2
0
 /**
  * Parses the current XML element.
  *
  * This method returns arn array with 3 properties:
  *   * name - A clark-notation xml element name.
  *   * value - The parsed value.
  *   * attributes - A key-value list of attributes.
  *
  * @return array
  */
 public function parseCurrentElement()
 {
     $name = $this->getClark();
     $attributes = [];
     if ($this->hasAttributes) {
         $attributes = $this->parseAttributes();
     }
     if (isset($this->elementMap[$name])) {
         $value = call_user_func([$this->elementMap[$name], 'deserializeXml'], $this);
     } else {
         $value = Element\Base::deserializeXml($this);
     }
     return ['name' => $name, 'value' => $value, 'attributes' => $attributes];
 }