AbstractEncryptedType   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 137
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 13
eloc 24
c 1
b 0
f 0
dl 0
loc 137
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getID() 0 3 1
A getEncoding() 0 3 1
A toXML() 0 29 5
A getType() 0 3 1
A getEncryptionMethod() 0 3 1
A getCipherData() 0 3 1
A getMimeType() 0 3 1
A getKeyInfo() 0 3 1
A __construct() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\XML\xenc;
6
7
use DOMElement;
8
use SimpleSAML\XMLSchema\Type\AnyURIValue;
9
use SimpleSAML\XMLSchema\Type\IDValue;
10
use SimpleSAML\XMLSchema\Type\StringValue;
11
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
12
13
use function strval;
14
15
/**
16
 * Abstract class representing encrypted data.
17
 *
18
 * @package simplesamlphp/xml-security
19
 */
20
abstract class AbstractEncryptedType extends AbstractXencElement
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSecurity\X...enc\AbstractXencElement was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
{
22
    /**
23
     * EncryptedData constructor.
24
     *
25
     * @param \SimpleSAML\XMLSecurity\XML\xenc\CipherData $cipherData The CipherData object of this EncryptedData.
26
     * @param \SimpleSAML\XMLSchema\Type\IDValue|null $id The Id attribute of this object. Optional.
27
     * @param \SimpleSAML\XMLSchema\Type\AnyURIValue|null $type The Type attribute of this object. Optional.
28
     * @param \SimpleSAML\XMLSchema\Type\StringValue|null $mimeType
29
     *   The MimeType attribute of this object. Optional.
30
     * @param \SimpleSAML\XMLSchema\Type\AnyURIValue|null $encoding
31
     *   The Encoding attribute of this object. Optional.
32
     * @param \SimpleSAML\XMLSecurity\XML\xenc\EncryptionMethod|null $encryptionMethod
33
     *   The EncryptionMethod object of this EncryptedData. Optional.
34
     * @param \SimpleSAML\XMLSecurity\XML\ds\KeyInfo|null $keyInfo The KeyInfo object of this EncryptedData. Optional.
35
     */
36
    public function __construct(
37
        protected CipherData $cipherData,
38
        protected ?IDValue $id = null,
39
        protected ?AnyURIValue $type = null,
40
        protected ?StringValue $mimeType = null,
41
        protected ?AnyURIValue $encoding = null,
42
        protected ?EncryptionMethod $encryptionMethod = null,
43
        protected ?KeyInfo $keyInfo = null,
44
    ) {
45
    }
46
47
48
    /**
49
     * Get the CipherData object.
50
     *
51
     * @return \SimpleSAML\XMLSecurity\XML\xenc\CipherData
52
     */
53
    public function getCipherData(): CipherData
54
    {
55
        return $this->cipherData;
56
    }
57
58
59
    /**
60
     * Get the value of the Encoding attribute.
61
     *
62
     * @return \SimpleSAML\XMLSchema\Type\AnyURIValue|null
63
     */
64
    public function getEncoding(): ?AnyURIValue
65
    {
66
        return $this->encoding;
67
    }
68
69
70
    /**
71
     * Get the EncryptionMethod object.
72
     *
73
     * @return \SimpleSAML\XMLSecurity\XML\xenc\EncryptionMethod|null
74
     */
75
    public function getEncryptionMethod(): ?EncryptionMethod
76
    {
77
        return $this->encryptionMethod;
78
    }
79
80
81
    /**
82
     * Get the value of the Id attribute.
83
     *
84
     * @return \SimpleSAML\XMLSchema\Type\IDValue
85
     */
86
    public function getID(): ?IDValue
87
    {
88
        return $this->id;
89
    }
90
91
92
    /**
93
     * Get the KeyInfo object.
94
     *
95
     * @return \SimpleSAML\XMLSecurity\XML\ds\KeyInfo|null
96
     */
97
    public function getKeyInfo(): ?KeyInfo
98
    {
99
        return $this->keyInfo;
100
    }
101
102
103
    /**
104
     * Get the value of the MimeType attribute.
105
     *
106
     * @return \SimpleSAML\XMLSchema\Type\StringValue
107
     */
108
    public function getMimeType(): ?StringValue
109
    {
110
        return $this->mimeType;
111
    }
112
113
114
    /**
115
     * Get the value of the Type attribute.
116
     *
117
     * @return \SimpleSAML\XMLSchema\Type\AnyURIValue|null
118
     */
119
    public function getType(): ?AnyURIValue
120
    {
121
        return $this->type;
122
    }
123
124
125
    /**
126
     * @inheritDoc
127
     */
128
    public function toXML(?DOMElement $parent = null): DOMElement
129
    {
130
        $e = $this->instantiateParentElement($parent);
131
132
        $id = $this->getId();
133
        if ($id !== null) {
134
            $e->setAttribute('Id', strval($id));
135
        }
136
137
        $type = $this->getType();
138
        if ($type !== null) {
139
            $e->setAttribute('Type', strval($type));
140
        }
141
142
        $mimeType = $this->getMimeType();
143
        if ($mimeType !== null) {
144
            $e->setAttribute('MimeType', strval($mimeType));
145
        }
146
147
        $encoding = $this->getEncoding();
148
        if ($encoding !== null) {
149
            $e->setAttribute('Encoding', strval($encoding));
150
        }
151
152
        $this->getEncryptionMethod()?->toXML($e);
153
        $this->getKeyInfo()?->toXML($e);
154
        $this->getCipherData()->toXML($e);
155
156
        return $e;
157
    }
158
}
159