FluentDOM\Loader\Html::load PHP Method

load() public method

See also: Loadable::load
public load ( string $source, string $contentType, array | Traversable | Options $options = [] ) : Document | Result | null
$source string
$contentType string
$options array | Traversable | Options
return FluentDOM\Document | Result | null
    public function load($source, $contentType, $options = [])
    {
        if ($this->supports($contentType)) {
            return $this->captureLibxmlErrors(function () use($source, $contentType, $options) {
                $selection = false;
                $document = new Document();
                $options = $this->getOptions($options);
                $loadOptions = $options[self::LIBXML_OPTIONS];
                if ($this->isFragment($contentType, $options)) {
                    $this->loadFragmentIntoDom($document, $source, $loadOptions);
                    $selection = $document->evaluate('/*');
                } else {
                    $options->isAllowed($sourceType = $options->getSourceType($source));
                    switch ($sourceType) {
                        case Options::IS_FILE:
                            $document->loadHTMLFile($source, $loadOptions);
                            break;
                        case Options::IS_STRING:
                        default:
                            $document->loadHTML($source, $loadOptions);
                            break;
                    }
                }
                return new Result($document, 'text/html', $selection);
            });
        }
        return NULL;
    }