AbstractLocalElement::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 33
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

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