Passed
Pull Request — master (#2)
by Tim
02:03
created

AbstractSignedXMLElement::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 3
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XML;
6
7
use DOMElement;
8
use SimpleSAML\XMLSecurity\XML\ds\Signature;
9
use SimpleSAML\XMLSecurity\XML\SignableElementInterface;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSecurity\X...ignableElementInterface 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...
10
use SimpleSAML\XMLSecurity\XML\SignedElementInterface;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSecurity\XML\SignedElementInterface 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...
11
12
/**
13
 * Abstract class to be implemented by all signed classes
14
 *
15
 * @package simplesamlphp/xml-security
16
 */
17
abstract class AbstractSignedXMLElement implements SignedElementInterface
18
{
19
    use SignedElementTrait;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XML\SignedElementTrait 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...
20
21
    /**
22
     * The signed DOM structure.
23
     *
24
     * @var \DOMElement
25
     */
26
    protected DOMElement $structure;
27
28
    /**
29
     * The unsigned elelement.
30
     *
31
     * @var \SimpleSAML\XMLSecurity\SignableElementInterface
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSecurity\SignableElementInterface 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...
32
     */
33
    protected SignableElementInterface $element;
34
35
36
    /**
37
     * Create/parse an alg:SigningMethod element.
38
     *
39
     * @param \DOMElement $xml
40
     * @param \SimpleSAML\XMLSecurity\XML\SignedElementInterface $elt
41
     * @param \SimpleSAML\XMLSecurity\XML\ds\Signature $signature
42
     */
43
    private function __construct(DOMElement $xml, SignedElementInterface $elt, Signature $signature)
44
    {
45
        $this->setStructure($xml);
46
        $this->setElement($elt);
47
        $this->setSignature($signature);
48
    }
49
50
51
    /**
52
     * Collect the value of the unsigned element
53
     *
54
     * @return \SimpleSAML\XMLSecurity\XML\SignableElementInterface
55
     */
56
    public function getElement(): SignableElementInterface
57
    {
58
        return $this->element;
59
    }
60
61
62
    /**
63
     * Set the value of the elment-property
64
     *
65
     * @param \SimpleSAML\XMLSecurity\XML\SignableElementInterface $elt
66
     */
67
    private function setElement(SignableElementInterface $elt): void
68
    {
69
        $this->element = $elt;
70
    }
71
72
73
    /**
74
     * Collect the value of the structure-property
75
     *
76
     * @return \DOMElement
77
     */
78
    public function getStructure(): DOMElement
79
    {
80
        return $this->structure;
81
    }
82
83
84
    /**
85
     * Set the value of the structure-property
86
     *
87
     * @param \DOMElement $structure
88
     */
89
    private function setStructure(DOMElement $structure): void
90
    {
91
        $this->structure = $structure;
92
    }
93
94
95
    /**
96
     * Create XML from this class
97
     *
98
     * @param \DOMElement|null $parent
99
     * @return \DOMElement
100
     */
101
    public function toXML(DOMElement $parent = null): DOMElement
102
    {
103
        return $this->structure;
104
    }
105
106
107
    /**
108
     * Create a class from XML
109
     *
110
     * @param \DOMElement $xml
111
     * @return self
112
     */
113
    abstract public static function fromXML(DOMElement $xml): object;
114
}
115