Code Duplication    Length = 21-23 lines in 2 locations

src/SAML2/XML/ds/KeyInfo.php 1 location

@@ 76-96 (lines=21) @@
73
     * @param \DOMElement $parent The element we should append this KeyInfo to.
74
     * @return \DOMElement
75
     */
76
    public function toXML(\DOMElement $parent)
77
    {
78
        assert('is_null($this->Id) || is_string($this->Id)');
79
        assert('is_array($this->info)');
80
81
        $doc = $parent->ownerDocument;
82
83
        $e = $doc->createElementNS(XMLSecurityDSig::XMLDSIGNS, 'ds:KeyInfo');
84
        $parent->appendChild($e);
85
86
        if (isset($this->Id)) {
87
            $e->setAttribute('Id', $this->Id);
88
        }
89
90
        /** @var \SAML2\XML\Chunk|\SAML2\XML\ds\KeyName|\SAML2\XML\ds\X509Data $n */
91
        foreach ($this->info as $n) {
92
            $n->toXML($e);
93
        }
94
95
        return $e;
96
    }
97
}
98

src/SAML2/XML/md/KeyDescriptor.php 1 location

@@ 77-99 (lines=23) @@
74
     * @param \DOMElement $parent The element we should append this KeyDescriptor to.
75
     * @return \DOMElement
76
     */
77
    public function toXML(\DOMElement $parent)
78
    {
79
        assert('is_null($this->use) || is_string($this->use)');
80
        assert('$this->KeyInfo instanceof \SAML2\XML\ds\KeyInfo');
81
        assert('is_array($this->EncryptionMethod)');
82
83
        $doc = $parent->ownerDocument;
84
85
        $e = $doc->createElementNS(Constants::NS_MD, 'md:KeyDescriptor');
86
        $parent->appendChild($e);
87
88
        if (isset($this->use)) {
89
            $e->setAttribute('use', $this->use);
90
        }
91
92
        $this->KeyInfo->toXML($e);
93
94
        foreach ($this->EncryptionMethod as $em) {
95
            $em->toXML($e);
96
        }
97
98
        return $e;
99
    }
100
}
101