Code Duplication    Length = 22-23 lines in 2 locations

src/SAML2/AuthnRequest.php 1 location

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

src/SAML2/Assertion.php 1 location

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