Code Duplication    Length = 22-23 lines in 2 locations

src/SAML2/Assertion.php 1 location

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

src/SAML2/AuthnRequest.php 1 location

@@ 845-866 (lines=22) @@
842
     *
843
     * @param \DOMElement $root The assertion element we should add the subject to.
844
     */
845
    private function addSubject(\DOMElement $root)
846
    {
847
        // If there is no nameId (encrypted or not) there is nothing to create a subject for
848
        if ($this->nameId === null && $this->encryptedNameId === null) {
849
            return;
850
        }
851
852
        $subject = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:Subject');
853
        $root->appendChild($subject);
854
855
        if ($this->encryptedNameId === null) {
856
            $this->nameId->toXML($subject);
857
        } else {
858
            $eid = $subject->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:EncryptedID');
859
            $eid->appendChild($subject->ownerDocument->importNode($this->encryptedNameId, true));
860
            $subject->appendChild($eid);
861
        }
862
863
        foreach ($this->subjectConfirmation as $sc) {
864
            $sc->toXML($subject);
865
        }
866
    }
867
868
    /**
869
     * Add a Conditions-node to the request.