protected function _createMockRssItem() { $item = new RssItem(); if (!is_null(static::VALUE_DATE)) { $item->setEventDate(\DateTime::createFromFormat(static::FORMAT_DATETIME, static::VALUE_DATE)); } $item->setTitle(static::VALUE_TITLE); $item->setUrl(static::VALUE_URL); $item->setGUID(static::VALUE_URL); $item->setCategory(static::VALUE_CATEGORY); $item->setDescription(static::VALUE_DESCRIPTION); return $item; }
/** * @param string $source * @return mixed */ public function parse($source) { $this->_initialize($source); $result = array(); $rowsList = $this->_xpath->query(static::XPATH_ROWS); foreach ($rowsList as $row) { $item = new RssItem(); $target = $this->_xpath->query(static::XPATH_URL, $row)->item(0); $url = sprintf(static::MASK_FULL_URL, static::BASE_DOMAIN, trim($target->attributes->getNamedItem('href')->nodeValue)); $year = trim($this->_xpath->query(static::XPATH_DATE_YEAR, $row)->item(0)->nodeValue); $month = trim($this->_xpath->query(static::XPATH_DATE_MONTH, $row)->item(0)->nodeValue); $day = trim($this->_xpath->query(static::XPATH_DATE_DAY, $row)->item(0)->nodeValue); $eventDate = \DateTime::createFromFormat(static::FORMAT_DATETIME, sprintf(static::MASK_DATETIME, $year, $month, $day)); $item->setEventDate($eventDate); $item->setTitle(trim($target->nodeValue)); $item->setUrl($url); $item->setGUID($url); $item->setCategory(trim($this->_xpath->query(static::XPATH_CATEGORY, $row)->item(0)->nodeValue)); $result[] = $item; } return $result; }