Completed
Push — master ( f72cfb...4ef12f )
by Tim
21s queued 18s
created

AbstractTopLevelElement::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

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