/** * Map SerializableSerpPage entries to SerpPageEntries. * The serialization format is resolved at runtime. * @param SerializableSerpPage $serializablePage * @param string $format * @return SerpPageEntryJSON|SerpPageEntryXML|SerpPageEntryYAML */ private function createEntries($serializablePage, $format) { $result = array(); $entries = $serializablePage->getEntries(); for ($i = 0; $i < count($entries); $i++) { $args = array($i + 1, $entries[$i]['url'], $entries[$i]['title'], $entries[$i]['snippet']); array_push($result, self::getFormatClassName($format, $args, true)); } return $result; }
/** * Extract relevant data from a SerializableSerpPage. * @param SerializableSerpPage $serializablePage * @return array */ public static function extractSerializablePageData($serializablePage) { $keyword = $serializablePage->getKeyword(); $pageNumber = $serializablePage->getPageNumber(); $age = $serializablePage->getAge()->format('Y-m-d'); return array($keyword, $pageNumber, $age); }