Code Duplication    Length = 22-23 lines in 2 locations

src/SAML2/AuthnRequest.php 1 location

@@ 786-807 (lines=22) @@
783
     *
784
     * @param \DOMElement $root The assertion element we should add the subject to.
785
     */
786
    private function addSubject(\DOMElement $root)
787
    {
788
        // If there is no nameId (encrypted or not) there is nothing to create a subject for
789
        if ($this->nameId === null && $this->encryptedNameId === null) {
790
            return;
791
        }
792
793
        $subject = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:Subject');
794
        $root->appendChild($subject);
795
796
        if ($this->encryptedNameId === null) {
797
            $this->nameId->toXML($subject);
798
        } else {
799
            $eid = $subject->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:EncryptedID');
800
            $eid->appendChild($subject->ownerDocument->importNode($this->encryptedNameId, true));
801
            $subject->appendChild($eid);
802
        }
803
804
        foreach ($this->subjectConfirmation as $sc) {
805
            $sc->toXML($subject);
806
        }
807
    }
808
}
809

src/SAML2/Assertion.php 1 location

@@ 1412-1434 (lines=23) @@
1409
     *
1410
     * @param \DOMElement $root The assertion element we should add the subject to.
1411
     */
1412
    private function addSubject(\DOMElement $root)
1413
    {
1414
        if ($this->nameId === null && $this->encryptedNameId === null) {
1415
            /* We don't have anything to create a Subject node for. */
1416
1417
            return;
1418
        }
1419
1420
        $subject = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:Subject');
1421
        $root->appendChild($subject);
1422
1423
        if ($this->encryptedNameId === null) {
1424
            $this->nameId->toXML($subject);
1425
        } else {
1426
            $eid = $subject->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:' . 'EncryptedID');
1427
            $subject->appendChild($eid);
1428
            $eid->appendChild($subject->ownerDocument->importNode($this->encryptedNameId, true));
1429
        }
1430
1431
        foreach ($this->SubjectConfirmation as $sc) {
1432
            $sc->toXML($subject);
1433
        }
1434
    }
1435
1436
1437
    /**