/** * @inheritdoc */ public function map(ParameterBag $item) { if (null === $this->crawler) { throw new \LogicException('setCrawler() should be called before map()'); } if (!$item instanceof ScrapedItemBag) { throw new TransformationFailedException(sprintf('Expected a %s instance', ScrapedItemBag::class)); } if ($url = call_user_func($this->originalUrlCallback, $this->crawler)) { $item->setOriginalUrl($url); } if ($id = call_user_func($this->originalIdCallback, $this->crawler)) { $item->setOriginalId($id); } if ($date = call_user_func($this->modificationDateCallback, $this->crawler)) { $item->setDatetimeModified($date); } return $item; }