You are here

public function Crawler::add in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dom-crawler/Crawler.php \Symfony\Component\DomCrawler\Crawler::add()

Adds a node to the current list of nodes.

This method uses the appropriate specialized add*() method based on the type of the argument.

Parameters

\DOMNodeList|\DOMNode|array|string|null $node A node:

Throws

\InvalidArgumentException When node is not the expected type.

2 calls to Crawler::add()
Crawler::addNodes in vendor/symfony/dom-crawler/Crawler.php
Adds an array of \DOMNode instances to the list of nodes.
Crawler::__construct in vendor/symfony/dom-crawler/Crawler.php
Constructor.

File

vendor/symfony/dom-crawler/Crawler.php, line 76

Class

Crawler
Crawler eases navigation of a list of \DOMElement objects.

Namespace

Symfony\Component\DomCrawler

Code

public function add($node) {
  if ($node instanceof \DOMNodeList) {
    $this
      ->addNodeList($node);
  }
  elseif ($node instanceof \DOMNode) {
    $this
      ->addNode($node);
  }
  elseif (is_array($node)) {
    $this
      ->addNodes($node);
  }
  elseif (is_string($node)) {
    $this
      ->addContent($node);
  }
  elseif (null !== $node) {
    throw new \InvalidArgumentException(sprintf('Expecting a DOMNodeList or DOMNode instance, an array, a string, or null, but got "%s".', is_object($node) ? get_class($node) : gettype($node)));
  }
}