Issues (311)

src/XML/ds/X509IssuerSerial.php (3 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\XML\ds;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
10
use SimpleSAML\XMLSchema\Exception\MissingElementException;
11
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
12
13
use function array_pop;
14
15
/**
16
 * Class representing a ds:X509IssuerSerial element.
17
 *
18
 * @package simplesaml/xml-security
19
 */
20
final class X509IssuerSerial extends AbstractDsElement
0 ignored issues
show
The type SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement 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
     * Initialize a X509SubjectName element.
24
     *
25
     * @param \SimpleSAML\XMLSecurity\XML\ds\X509IssuerName $X509IssuerName
26
     * @param \SimpleSAML\XMLSecurity\XML\ds\X509SerialNumber $X509SerialNumber
27
     */
28
    public function __construct(
29
        protected X509IssuerName $X509IssuerName,
0 ignored issues
show
The type SimpleSAML\XMLSecurity\XML\ds\X509IssuerName 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...
30
        protected X509SerialNumber $X509SerialNumber,
0 ignored issues
show
The type SimpleSAML\XMLSecurity\XML\ds\X509SerialNumber 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...
31
    ) {
32
    }
33
34
35
    /**
36
     * Collect the value of the X509IssuerName-property
37
     *
38
     * @return \SimpleSAML\XMLSecurity\XML\ds\X509IssuerName
39
     */
40
    public function getIssuerName(): X509IssuerName
41
    {
42
        return $this->X509IssuerName;
43
    }
44
45
46
    /**
47
     * Collect the value of the X509SerialNumber-property
48
     *
49
     * @return \SimpleSAML\XMLSecurity\XML\ds\X509SerialNumber
50
     */
51
    public function getSerialNumber(): X509SerialNumber
52
    {
53
        return $this->X509SerialNumber;
54
    }
55
56
57
    /**
58
     * Convert XML into a X509IssuerSerial
59
     *
60
     * @param \DOMElement $xml The XML element we should load
61
     *
62
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
63
     *   If the qualified name of the supplied element is wrong
64
     */
65
    public static function fromXML(DOMElement $xml): static
66
    {
67
        Assert::same($xml->localName, 'X509IssuerSerial', InvalidDOMElementException::class);
68
        Assert::same($xml->namespaceURI, X509IssuerSerial::NS, InvalidDOMElementException::class);
69
70
        $issuer = X509IssuerName::getChildrenOfClass($xml);
71
        $serial = X509SerialNumber::getChildrenOfClass($xml);
72
73
        Assert::minCount($issuer, 1, MissingElementException::class);
74
        Assert::maxCount($issuer, 1, TooManyElementsException::class);
75
76
        Assert::minCount($serial, 1, MissingElementException::class);
77
        Assert::maxCount($serial, 1, TooManyElementsException::class);
78
79
        return new static(
80
            array_pop($issuer),
81
            array_pop($serial),
82
        );
83
    }
84
85
86
    /**
87
     * Convert this X509IssuerSerial element to XML.
88
     *
89
     * @param \DOMElement|null $parent The element we should append this X509IssuerSerial element to.
90
     */
91
    public function toXML(?DOMElement $parent = null): DOMElement
92
    {
93
        $e = $this->instantiateParentElement($parent);
94
95
        $this->getIssuerName()->toXML($e);
96
        $this->getSerialNumber()->toXML($e);
97
98
        return $e;
99
    }
100
}
101