AbstractTopLevelAttribute::__construct()   A
last analyzed

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