/** * @param SimpleXMLElement $item * * @return Article * @throws \imnotjames\Syndicator\Exceptions\InvalidURIException */ private function parseArticle(SimpleXMLElement $item) { $article = new Article(); $article->setTitle((string) $item->title); $article->setURI((string) $item->link); $article->setDescription((string) $item->description); if (isset($item->author)) { $article->setAuthor($this->parseContact($item->author)); } if (isset($item->pubDate)) { $article->setDatePublished($this->parseDateTime($item->pubDate)); } if (isset($item->category)) { foreach ($item->category as $category) { $article->addCategory($this->parseCategory($category)); } } if (isset($item->enclosure)) { foreach ($item->enclosure as $enclosure) { $article->addAttachment($this->parseEnclosure($enclosure)); } } if (isset($item->guid)) { $article->setID((string) $item->guid); } if (isset($item->source)) { $article->setSource($this->parseSource($item->source)); } return $article; }