Passed
Push — master ( 8413b2...00f101 )
by Tim
02:19
created

AbstractTopLevelAttribute::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 8
dl 0
loc 19
rs 9.9666
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\XMLSchema\XML;
6
7
use SimpleSAML\XMLSchema\Type\{IDValue, NCNameValue, QNameValue, StringValue};
8
use SimpleSAML\XMLSchema\XML\Enumeration\NamespaceEnum;
9
10
/**
11
 * Abstract class representing the topLevelAttribute-type.
12
 *
13
 * @package simplesamlphp/xml-common
14
 */
15
abstract class AbstractTopLevelAttribute extends AbstractAttribute
16
{
17
    /** The namespace-attribute for the xs:anyAttribute element */
18
    public const XS_ANY_ATTR_NAMESPACE = NamespaceEnum::Other;
19
20
21
    /**
22
     * TopLevelAttribute constructor
23
     *
24
     * @param \SimpleSAML\XMLSchema\Type\NCNameValue $name
25
     * @param \SimpleSAML\XMLSchema\Type\QNameValue $type
26
     * @param \SimpleSAML\XMLSchema\Type\StringValue|null $default
27
     * @param \SimpleSAML\XMLSchema\Type\StringValue|null $fixed
28
     * @param \SimpleSAML\XMLSchema\XML\LocalSimpleType|null $simpleType
29
     * @param \SimpleSAML\XMLSchema\XML\Annotation|null $annotation
30
     * @param \SimpleSAML\XMLSchema\Type\IDValue|null $id
31
     * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
32
     */
33
    public function __construct(
34
        NCNameValue $name,
35
        ?QNameValue $type = null,
36
        ?StringValue $default = null,
37
        ?StringValue $fixed = null,
38
        ?LocalSimpleType $simpleType = null,
39
        ?Annotation $annotation = null,
40
        ?IDValue $id = null,
41
        array $namespacedAttributes = [],
42
    ) {
43
        parent::__construct(
44
            name: $name,
45
            type: $type,
46
            default: $default,
47
            fixed: $fixed,
48
            simpleType: $simpleType,
49
            annotation: $annotation,
50
            id: $id,
51
            namespacedAttributes: $namespacedAttributes,
52
        );
53
    }
54
}
55