Passed
Pull Request — master (#306)
by Tim
02:07
created

UnknownRoleDescriptor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 12
dl 0
loc 26
rs 9.8666
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\md;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\SAML2\Utils\XPath;
10
use SimpleSAML\XML\AbstractElement;
11
use SimpleSAML\XML\Chunk;
12
use SimpleSAML\XML\Exception\InvalidDOMElementException;
13
use SimpleSAML\XML\Exception\TooManyElementsException;
14
use SimpleSAML\XML\Utils as XMLUtils;
15
use SimpleSAML\XMLSecurity\XML\ds\Signature;
16
17
use function array_pop;
18
use function preg_split;
19
20
/**
21
 * Class representing unknown RoleDescriptors.
22
 *
23
 * @package simplesamlphp/saml2
24
 */
25
final class UnknownRoleDescriptor extends AbstractRoleDescriptor
26
{
27
    /**
28
     * Initialize an unknown RoleDescriptor.
29
     *
30
     * @param \SimpleSAML\XML\Chunk $chunk The whole RoleDescriptor element as a chunk object.
31
     * @param string $type
32
     * @param string[] $protocolSupportEnumeration A set of URI specifying the protocols supported.
33
     * @param string|null $ID The ID for this document. Defaults to null.
34
     * @param int|null $validUntil Unix time of validity for this document. Defaults to null.
35
     * @param string|null $cacheDuration Maximum time this document can be cached. Defaults to null.
36
     * @param \SimpleSAML\SAML2\XML\md\Extensions|null $extensions An Extensions object. Defaults to null.
37
     * @param string|null $errorURL An URI where to redirect users for support. Defaults to null.
38
     * @param \SimpleSAML\SAML2\XML\md\KeyDescriptor[] $keyDescriptors An array of KeyDescriptor elements.
39
     *   Defaults to an empty array.
40
     * @param \SimpleSAML\SAML2\XML\md\Organization|null $organization The organization running this entity. Defaults to null.
41
     * @param \SimpleSAML\SAML2\XML\md\ContactPerson[] $contacts An array of contacts for this entity. Defaults to an empty array.
42
     * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
0 ignored issues
show
Bug introduced by
The type SimpleSAML\SAML2\XML\md\list 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...
43
     */
44
    protected function __construct(
45
        protected Chunk $chunk,
46
        string $type,
47
        array $protocolSupportEnumeration,
48
        ?string $ID = null,
49
        ?int $validUntil = null,
50
        ?string $cacheDuration = null,
51
        ?Extensions $extensions = null,
52
        ?string $errorURL = null,
53
        array $keyDescriptors = [],
54
        ?Organization $organization = null,
55
        array $contacts = [],
56
        array $namespacedAttributes = []
57
    ) {
58
        parent::__construct(
59
            $type,
60
            $protocolSupportEnumeration,
61
            $ID,
62
            $validUntil,
63
            $cacheDuration,
64
            $extensions,
65
            $errorURL,
66
            $keyDescriptors,
67
            $organization,
68
            $contacts,
69
            $namespacedAttributes,
70
        );
71
    }
72
73
74
    /**
75
     * Get the raw version of this RoleDescriptor as a Chunk.
76
     *
77
     * @return \SimpleSAML\XML\Chunk
78
     */
79
    public function getRawRoleDescriptor(): Chunk
80
    {
81
        return $this->chunk;
82
    }
83
84
85
    /**
86
     * Convert this RoleDescriptor to XML.
87
     *
88
     * @param \DOMElement|null $parent The element we are converting to XML.
89
     * @return \DOMElement The XML element after adding the data corresponding to this unknown RoleDescriptor.
90
     */
91
    public function toXML(DOMElement $parent = null): DOMElement
92
    {
93
        return $this->getRawRoleDescriptor()->toXML($parent);
94
    }
95
}
96