+ }\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
+ $dateStringParts = explode('/', explode(':', $header->nodeValue)[0]);\r
+ if ( strlen($dateStringParts[2]) === 2 ) {\r
+ $dateStringParts[2] = '20' . $dateStringParts[2];\r
+ }\r
+ $episodeDate = DateTime::createFromFormat(DATE_FORM, implode("/", $dateStringParts));\r
+ if ($episodeDate < $lastDate) {\r
+ break;\r
+ }\r
+ $episodeDates[] = $episodeDate;\r
+ }\r
+ }\r
+ return $episodeDates;\r