AbstractSimpleRestrictionType::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 8
dl 0
loc 22
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\QNameValue;
9
10
/**
11
 * Abstract class representing the simpleRestrictionType-type.
12
 *
13
 * @package simplesamlphp/xml-common
14
 */
15
abstract class AbstractSimpleRestrictionType extends AbstractRestrictionType
16
{
17
    /**
18
     * AbstractRestrictionType constructor
19
     *
20
     * @param \SimpleSAML\XMLSchema\Type\QNameValue $base
21
     * @param \SimpleSAML\XMLSchema\XML\LocalSimpleType|null $localSimpleType
22
     * @param array<\SimpleSAML\XMLSchema\XML\Interface\FacetInterface> $facets
23
     * @param (
24
     *    \SimpleSAML\XMLSchema\XML\LocalAttribute|
25
     *    \SimpleSAML\XMLSchema\XML\ReferencedAttributeGroup
26
     * )[] $attributes
27
     * @param \SimpleSAML\XMLSchema\XML\AnyAttribute|null $anyAttribute
28
     * @param \SimpleSAML\XMLSchema\XML\Annotation|null $annotation
29
     * @param \SimpleSAML\XMLSchema\Type\IDValue|null $id
30
     * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
31
     */
32
    public function __construct(
33
        QNameValue $base,
34
        // xs:simpleRestrictionModel
35
        ?LocalSimpleType $localSimpleType = null,
36
        array $facets = [],
37
        // xs:attrDecls
38
        array $attributes = [],
39
        ?AnyAttribute $anyAttribute = null,
40
        // parent defined
41
        ?Annotation $annotation = null,
42
        ?IDValue $id = null,
43
        array $namespacedAttributes = [],
44
    ) {
45
        parent::__construct(
46
            base: $base,
47
            localSimpleType: $localSimpleType,
48
            facets: $facets,
49
            attributes: $attributes,
50
            anyAttribute: $anyAttribute,
51
            annotation: $annotation,
52
            id: $id,
53
            namespacedAttributes: $namespacedAttributes,
54
        );
55
    }
56
}
57