public function toDOMElement()

in src/Facebook/InstantArticles/Elements/Footer.php [165:203]


    public function toDOMElement($document = null)
    {
        if (!$document) {
            $document = new \DOMDocument();
        }

        $footer = $document->createElement('footer');

        // Footer markup
        if ($this->credits) {
            $aside = $document->createElement('aside');
            if (is_array($this->credits)) {
                foreach ($this->credits as $paragraph) {
                    Element::appendChild($aside, $paragraph, $document);
                }
            } else {
                $aside->appendChild($document->createTextNode($this->credits));
            }
            $footer->appendChild($aside);
        }

        if ($this->copyright) {
            if (Type::is($this->copyright, Type::STRING)) {
                $small = $document->createElement('small');
                $small->appendChild($document->createTextNode($this->copyright));
                $footer->appendChild($small);
            } else {
                Element::appendChild($footer, $this->copyright, $document);
            }
        }

        Element::appendChild($footer, $this->relatedArticles, $document);

        if (!$this->credits && !$this->copyright && !$this->relatedArticles) {
            $footer->appendChild($document->createTextNode(''));
        }

        return $footer;
    }