logger = $logger; if (empty($restaurants) || !is_array($restaurants)) { throw new InvalidArgumentException("Array argument required"); } $this->restaurants = $restaurants; } public function parse() { foreach ($this->restaurants as $restaurant) { $source = file_get_contents($restaurant->getUrl()); if ($source === false) { throw new RuntimeException("Can't read source address: " . $restaurant->getUrl()); } $dom = new DOMDocument(); @$dom->loadHTML($source); $xpath_obj = new DOMXPath($dom); $this->logger->log("Restaurant: " . $restaurant->getName() . "".$this->logger->newLine()); foreach ($restaurant->getXpaths() as $name => $xpath) { $found = $xpath_obj->query($xpath); if ($found === false || $found->length === 0) { continue; } $this->logger->log("$name"); $this->logger->log(""); if (!$exists) { $this->logger->log("Hovno. Nic nemaju." . $this->logger->newLine()); } } $this->logger->log($this->logger->newLine()); } } }