public static function fromHTML($html, $url = null)
    {
        if ($html instanceof MessageInterface) {
            $message = $html;
            $html    = $message->getBody() . '';

            if (!isset($url) && $message instanceof RequestInterface) {
                $url = $message->getUri() . '';
            }
        }

        $index_time = microtime(true);
        if (isset(self::$_mockup_class)) {
            $doc = new self::$_mockup_class($html, false);
        } else {
            $doc = new self($html, false);
        }
        if ($url) {
            $doc->location($url);
        }
        if (!empty($message)) {
            $doc->message     = $message;
            $doc->headers     = $message->getHeaders();
            $doc->source_type = 'message';

            if (!empty(self::$last_http_result) && self::$last_http_result->response === $message) {
                self::$last_http_result->body = $html;
            }
        }
        $doc->index();
        $index_time      = microtime(true) - $index_time;
        $doc->index_time = $index_time * 1000;
        return $doc;
    }