public function do_print(\Podlove\Chapters\Chapters $chapters) { $xml = new \SimpleXMLElement('<psc:chapters version="1.2" xmlns:psc="http://podlove.org/simple-chapters" />'); $xml = array_reduce($chapters->toArray(), function ($xml, $chapter) { $child = $xml->addChild('psc:chapter'); $child->addAttribute('start', $chapter->get_time()); $child->addAttribute('title', $chapter->get_title()); if ($chapter->get_link()) { $child->addAttribute('href', $chapter->get_link()); } if ($chapter->get_image()) { $child->addAttribute('image', $chapter->get_image()); } return $xml; }, $xml); $xml_string = $xml->asXML(); $xml_string = $this->format_xml($xml_string); $xml_string = $this->remove_xml_header($xml_string); return $xml_string; }
public function do_print(\Podlove\Chapters\Chapters $chapters) { return implode("\n", array_map(function ($chapter) { return $chapter->get_time() . ' ' . $chapter->get_title() . ($chapter->get_link() ? ' <' . $chapter->get_link() . '>' : ''); }, $chapters->toArray())); }
public function do_print(\Podlove\Chapters\Chapters $chapters) { return json_encode(array_map(function ($chapter) { return (object) array('start' => $chapter->get_time(), 'title' => $chapter->get_title(), 'href' => $chapter->get_link(), 'image' => $chapter->get_image()); }, $chapters->toArray())); }