public function parse($dhtml)
{
$dhtml = $this->prepare($dhtml);
libxml_use_internal_errors(true);
libxml_clear_errors();
$droot = new \SimpleXMLElement($dhtml, LIBXML_NONET);
if ($droot->attributes()->class != 'methodsynopsis dc-description') {
throw new \Exception('Invalid method description html');
}
$errors = libxml_get_errors();
$method = self::$defaultMethod;
foreach ($droot as $element) {
$class = $element->attributes()->class;
$text = strip_tags($element->asXML());
if ($class == 'modifier') {
$method['modifier'][$text] = $text;
} elseif ($class == 'type') {
$method['type'] = $text;
} elseif ($class == 'methodname') {
$method['name'] = $text;
} elseif ($class == 'methodparam') {
if ($element != 'void') {
$param = $this->parseParam($element);
$method['params'][] = $param;
}
} else {
throw new \Exception('Unknown method defination class <' . $class . '>');
}
}
return $method;
}