Symfony\Component\DomCrawler\Crawler::clear PHP Method

clear() public method

Removes all the nodes.
public clear ( )
    public function clear()
    {
        $this->nodes = array();
        $this->document = null;
    }

Usage Example

 /**
  * @param string $url
  * @param array  $tags
  *
  * @return WatchLink
  */
 public function extract(string $url, array $tags) : WatchLink
 {
     $watchLink = new WatchLink();
     $watchLink->setUrl($url);
     $this->crawler->clear();
     $this->crawler->addHtmlContent($this->fetcher->fetch($url));
     $watchLink->setName($this->extractTitle());
     $watchLink->setDescription($this->extractDescription());
     $watchLink->setImage($this->extractImage());
     foreach ($tags as $tag) {
         $watchLink->addTag($this->tagRepository->findOrCreate($tag));
     }
     return $watchLink;
 }
All Usage Examples Of Symfony\Component\DomCrawler\Crawler::clear