Passed
Pull Request — master (#225)
by Jaime Pérez
02:23
created

EncryptedAssertion   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 35
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A wasSignedAtConstruction() 0 3 1
A decrypt() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SAML2\XML\saml;
6
7
use RobRichards\XMLSecLibs\XMLSecurityKey;
8
use SAML2\XML\EncryptedElementInterface;
9
use SAML2\XML\EncryptedElementTrait;
10
use SAML2\Utils;
11
use SAML2\XML\AbstractXMLElement;
12
13
/**
14
 * Class handling encrypted assertions.
15
 *
16
 * @package SimpleSAMLphp
17
 */
18
class EncryptedAssertion extends AbstractSamlElement implements EncryptedElementInterface
19
{
20
    use EncryptedElementTrait;
1 ignored issue
show
introduced by
The trait SAML2\XML\EncryptedElementTrait requires some properties which are not provided by SAML2\XML\saml\EncryptedAssertion: $localName, $namespaceURI
Loading history...
21
22
    /**
23
     * @var bool
24
     */
25
    protected $wasSignedAtConstruction = false;
26
27
28
    /**
29
     * @inheritDoc
30
     *
31
     * @return \SAML2\XML\saml\Assertion
32
     * @throws \Exception
33
     *
34
     * @psalm-suppress MismatchingDocblockReturnType
35
     * @psalm-suppress ImplementedReturnTypeMismatch
36
     */
37
    public function decrypt(XMLSecurityKey $key, array $blacklist = []): AbstractXMLElement
38
    {
39
        $assertionXML = Utils::decryptElement($this->encryptedData->toXML(), $key, $blacklist);
40
41
        Utils::getContainer()->debugMessage($assertionXML, 'decrypt');
42
43
        return new Assertion($assertionXML);
1 ignored issue
show
Bug Best Practice introduced by
The expression return new SAML2\XML\saml\Assertion($assertionXML) returns the type SAML2\XML\saml\Assertion which is incompatible with the type-hinted return SAML2\XML\AbstractXMLElement.
Loading history...
44
    }
45
46
47
    /**
48
     * @return bool
49
     */
50
    public function wasSignedAtConstruction(): bool
51
    {
52
        return $this->wasSignedAtConstruction;
53
    }
54
}
55