AbstractTopLevelElement::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 15
nc 1
nop 14
dl 0
loc 31
rs 9.7666
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\BooleanValue;
8
use SimpleSAML\XMLSchema\Type\IDValue;
9
use SimpleSAML\XMLSchema\Type\NCNameValue;
10
use SimpleSAML\XMLSchema\Type\QNameValue;
11
use SimpleSAML\XMLSchema\Type\Schema\BlockSetValue;
12
use SimpleSAML\XMLSchema\Type\Schema\DerivationSetValue;
13
use SimpleSAML\XMLSchema\Type\StringValue;
14
15
/**
16
 * Abstract class representing the topLevelElement-type.
17
 *
18
 * @package simplesamlphp/xml-common
19
 */
20
abstract class AbstractTopLevelElement extends AbstractElement
21
{
22
    /**
23
     * Element constructor
24
     *
25
     * @param \SimpleSAML\XMLSchema\Type\NCNameValue $name
26
     * @param \SimpleSAML\XMLSchema\XML\LocalSimpleType|\SimpleSAML\XMLSchema\XML\LocalComplexType|null $localType
27
     * @param array<\SimpleSAML\XMLSchema\XML\Interface\IdentityConstraintInterface> $identityConstraint
28
     * @param \SimpleSAML\XMLSchema\Type\QNameValue|null $type
29
     * @param \SimpleSAML\XMLSchema\Type\QNameValue|null $substitutionGroup
30
     * @param \SimpleSAML\XMLSchema\Type\StringValue|null $default
31
     * @param \SimpleSAML\XMLSchema\Type\StringValue|null $fixed
32
     * @param \SimpleSAML\XMLSchema\Type\BooleanValue|null $nillable
33
     * @param \SimpleSAML\XMLSchema\Type\BooleanValue|null $abstract
34
     * @param \SimpleSAML\XMLSchema\Type\Schema\DerivationSetValue|null $final
35
     * @param \SimpleSAML\XMLSchema\Type\Schema\BlockSetValue|null $block
36
     * @param \SimpleSAML\XMLSchema\XML\Annotation|null $annotation
37
     * @param \SimpleSAML\XMLSchema\Type\IDValue|null $id
38
     * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
39
     */
40
    public function __construct(
41
        NCNameValue $name,
42
        LocalSimpleType|LocalComplexType|null $localType = null,
43
        array $identityConstraint = [],
44
        ?QNameValue $type = null,
45
        ?QNameValue $substitutionGroup = null,
46
        ?StringValue $default = null,
47
        ?StringValue $fixed = null,
48
        ?BooleanValue $nillable = null,
49
        ?BooleanValue $abstract = null,
50
        ?DerivationSetValue $final = null,
51
        ?BlockSetValue $block = null,
52
        ?Annotation $annotation = null,
53
        ?IDValue $id = null,
54
        array $namespacedAttributes = [],
55
    ) {
56
        parent::__construct(
57
            name: $name,
58
            localType: $localType,
59
            identityConstraint: $identityConstraint,
60
            type: $type,
61
            substitutionGroup: $substitutionGroup,
62
            default: $default,
63
            fixed: $fixed,
64
            nillable: $nillable,
65
            abstract: $abstract,
66
            final: $final,
67
            block: $block,
68
            annotation: $annotation,
69
            id: $id,
70
            namespacedAttributes: $namespacedAttributes,
71
        );
72
    }
73
}
74