+ }\r
+ \r
+ /**\r
+ * Go through the DOM elements provided and pull out the Dates of all marketplace\r
+ * pod episodes in the provided list.\r
+ * \r
+ * @param DomNodeList $headers The elements with a header tag from the DOM\r
+ * @param DateTime $lastDate The date of the most recent episode from the DB\r
+ */\r
+ function parseEpisodeDate(DomNodeList $headers, DateTime $lastDate): array {\r
+ $episodeDates = [];\r
+ foreach ($headers as $header) {\r
+ if ($header->hasAttribute('class') && $header->getAttribute('class') === 'river--hed') {\r
+ $episodeAnchorHref = $header->firstChild->getAttribute('href');\r
+ $dateString = explode('/', $episodeAnchorHref)[3];\r
+ $episodeDate = DateTime::createFromFormat(DATE_FORM, $dateString);\r
+ if ($episodeDate < $lastDate) {\r
+ break;\r
+ }\r
+ $episodeDates[] = $episodeDate;\r
+ }\r
+ }\r
+ return $episodeDates;\r
+ }\r