Code Duplication    Length = 22-23 lines in 2 locations

src/SAML2/Assertion.php 1 location

@@ 1368-1390 (lines=23) @@
1365
     *
1366
     * @param \DOMElement $root The assertion element we should add the subject to.
1367
     */
1368
    private function addSubject(\DOMElement $root)
1369
    {
1370
        if ($this->nameId === null && $this->encryptedNameId === null) {
1371
            /* We don't have anything to create a Subject node for. */
1372
1373
            return;
1374
        }
1375
1376
        $subject = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:Subject');
1377
        $root->appendChild($subject);
1378
1379
        if ($this->encryptedNameId === null) {
1380
            Utils::addNameId($subject, $this->nameId);
1381
        } else {
1382
            $eid = $subject->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:' . 'EncryptedID');
1383
            $subject->appendChild($eid);
1384
            $eid->appendChild($subject->ownerDocument->importNode($this->encryptedNameId, true));
1385
        }
1386
1387
        foreach ($this->SubjectConfirmation as $sc) {
1388
            $sc->toXML($subject);
1389
        }
1390
    }
1391
1392
1393
    /**

src/SAML2/AuthnRequest.php 1 location

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