original_string: public static function toArray($obj)
      {
          if ($obj instanceof DOMNode) {
              $obj = simplexml_import_dom($obj);
          }
          if (!($obj instanceof SimpleXMLElement)) {
              throw new XmlException('The input is not instance of SimpleXMLElement, DOMDocument or DOMNode.');
          }
          $result = [];
          $namespaces = array_merge(['' => ''], $obj->getNamespaces(true));
          static::_toArray($obj, $result, '', array_keys($namespaces));
  
          return $result;
      }
code: public static function toArray($obj)
      {
          if ($obj instanceof DOMNode) {
              $obj = simplexml_import_dom($obj);
          }
          if (!($obj instanceof SimpleXMLElement)) {
              throw new XmlException('The input is not instance of SimpleXMLElement, DOMDocument or DOMNode.');
          }
          $result = [];
          $namespaces = array_merge(['' => ''], $obj->getNamespaces(true));
          static::_toArray($obj, $result, '', array_keys($namespaces));
  
          return $result;
      }
code_tokens: public static function toArray ( $ obj ) { if ( $ obj instanceof DOMNode ) { $ obj = simplexml_import_dom ( $ obj ) ; } if ( ! ( $ obj instanceof SimpleXMLElement ) ) { throw new XmlException ( 'The input is not instance of SimpleXMLElement, DOMDocument or DOMNode.' ) ; } $ result = [ ] ; $ namespaces = array_merge ( [ '' => '' ] , $ obj -> getNamespaces ( true ) ) ; static :: _toArray ( $ obj , $ result , '' , array_keys ( $ namespaces ) ) ; return $ result ; }
docstring: Returns this XML structure as an array.
  
  @param \SimpleXMLElement|\DOMDocument|\DOMNode $obj SimpleXMLElement, DOMDocument or DOMNode instance
  @return array Array representation of the XML structure.
  @throws \Cake\Utility\Exception\XmlException
docstring_tokens: Returns this XML structure as an array .