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

AbstractNarrowMaxMin   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
dl 0
loc 57
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 36 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSchema\XML\xs;
6
7
use SimpleSAML\XML\Assert\Assert;
8
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
9
use SimpleSAML\XMLSchema\Type\Builtin\{BooleanValue, IDValue, NCNameValue, QNameValue, StringValue};
10
use SimpleSAML\XMLSchema\Type\{BlockSetValue, DerivationSetValue, FormChoiceValue, MaxOccursValue, MinOccursValue};
11
12
use function strval;
13
14
/**
15
 * Abstract class representing the narrowMaxMin-type.
16
 *
17
 * @package simplesamlphp/xml-common
18
 */
19
abstract class AbstractNarrowMaxMin extends AbstractLocalElement
20
{
21
    /**
22
     * Element constructor
23
     *
24
     * @param \SimpleSAML\XMLSchema\Type\Builtin\NCNameValue|null $name
25
     * @param \SimpleSAML\XMLSchema\Type\Builtin\QNameValue|null $reference
26
     * @param \SimpleSAML\XMLSchema\XML\xs\LocalSimpleType|\SimpleSAML\XMLSchema\XML\xs\LocalComplexType|null $localType
27
     * @param array<\SimpleSAML\XMLSchema\XML\xs\IdentityConstraintInterface> $identityConstraint
28
     * @param \SimpleSAML\XMLSchema\Type\Builtin\QNameValue|null $type
29
     * @param \SimpleSAML\XMLSchema\Type\MinOccursValue|null $minOccurs
30
     * @param \SimpleSAML\XMLSchema\Type\MaxOccursValue|null $maxOccurs
31
     * @param \SimpleSAML\XMLSchema\Type\Builtin\StringValue|null $default
32
     * @param \SimpleSAML\XMLSchema\Type\Builtin\StringValue|null $fixed
33
     * @param \SimpleSAML\XMLSchema\Type\Builtin\BooleanValue|null $nillable
34
     * @param \SimpleSAML\XMLSchema\Type\BlockSetValue|null $block
35
     * @param \SimpleSAML\XMLSchema\Type\FormChoiceValue|null $form
36
     * @param \SimpleSAML\XMLSchema\XML\xs\Annotation|null $annotation
37
     * @param \SimpleSAML\XMLSchema\Type\Builtin\IDValue|null $id
38
     * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
39
     */
40
    public function __construct(
41
        ?NCNameValue $name = null,
42
        ?QNameValue $reference = null,
43
        LocalSimpleType|LocalComplexType|null $localType = null,
44
        array $identityConstraint = [],
45
        ?QNameValue $type = null,
46
        ?MinOccursValue $minOccurs = null,
47
        ?MaxOccursValue $maxOccurs = null,
48
        ?StringValue $default = null,
49
        ?StringValue $fixed = null,
50
        ?BooleanValue $nillable = null,
51
        ?BlockSetValue $block = null,
52
        ?FormChoiceValue $form = null,
53
        ?Annotation $annotation = null,
54
        ?IDValue $id = null,
55
        array $namespacedAttributes = [],
56
    ) {
57
        Assert::oneOf(strval($minOccurs), ['0', '1'], SchemaViolationException::class);
58
        Assert::oneOf(strval($maxOccurs), ['0', '1'], SchemaViolationException::class);
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