public function toDOMElement()

in src/Facebook/InstantArticles/Elements/Author.php [170:200]


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

        $author_url = $this->url ? $this->url : null;
        $is_fb_author = strpos($author_url, 'facebook.com') !== false;

        // Creates the root tag <address></address>
        $element = $document->createElement('address');

        // Creates the <a href...></> tag
        $ahref = $document->createElement('a');
        if ($author_url) {
            $ahref->setAttribute('href', $author_url);
        }
        if ($is_fb_author) {
            $ahref->setAttribute('rel', 'facebook');
        }
        if ($this->roleContribution) {
            $ahref->setAttribute('title', $this->roleContribution);
        }
        $ahref->appendChild($document->createTextNode($this->name));
        $element->appendChild($ahref);

        // Appends author description
        $element->appendChild($document->createTextNode($this->description));

        return $element;
    }