public static function build($input, array $options = [])
    {
        if (!\is_array($options)) {
            $options = ['return' => (string)$options];
        }
        $defaults = [
            'return' => 'simplexml',
        ];
        $options = array_merge($defaults, $options);

        if (is_array($input) || is_object($input)) {
            return self::fromArray((array)$input, $options);
        }

        if (strpos($input, '<') !== false) {
            if ($options['return'] === 'simplexml' || $options['return'] === 'simplexmlelement') {
                return new \SimpleXMLElement($input, LIBXML_NOCDATA);
            }
            $dom = new \DOMDocument();
            $dom->loadXML($input);

            return $dom;
        }

        if (file_exists($input) || strpos($input, 'http://') === 0 || strpos($input, 'https://') === 0) {
            if ($options['return'] === 'simplexml' || $options['return'] === 'simplexmlelement') {
                return new \SimpleXMLElement($input, LIBXML_NOCDATA, true);
            }
            $dom = new \DOMDocument();
            $dom->load($input);

            return $dom;
        }

        if (!\is_string($input)) {
            throw new \RuntimeException(Tools::poorManTranslate('fts-shared', 'Invalid input.'));
        }
        throw new \RuntimeException(Tools::poorManTranslate('fts-shared', 'XML cannot be read.'));
    }