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

AbstractAll   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 45
rs 10
c 1
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 29 3
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\IDValue;
10
use SimpleSAML\XMLSchema\Type\{MinOccursValue, MaxOccursValue};
11
use SimpleSAML\XMLSchema\XML\xs\NamespaceEnum;
12
13
/**
14
 * Abstract class representing the explicitGroup-type.
15
 *
16
 * @package simplesamlphp/xml-common
17
 */
18
abstract class AbstractAll extends AbstractExplicitGroup
19
{
20
    /** The namespace-attribute for the xs:anyAttribute element */
21
    public const XS_ANY_ATTR_NAMESPACE = NamespaceEnum::Other;
22
23
24
    /**
25
     * All constructor
26
     *
27
     * @param \SimpleSAML\XMLSchema\Type\MinOccursValue|null $minOccurs
28
     * @param \SimpleSAML\XMLSchema\Type\MaxOccursValue|null $maxOccurs
29
     * @param \SimpleSAML\XMLSchema\XML\xs\NarrowMaxMinElement[] $particles
30
     * @param \SimpleSAML\XMLSchema\XML\xs\Annotation|null $annotation
31
     * @param \SimpleSAML\XMLSchema\Type\Builtin\IDValue|null $id
32
     * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
33
     */
34
    public function __construct(
35
        ?MinOccursValue $minOccurs = null,
36
        ?MaxOccursValue $maxOccurs = null,
37
        array $particles = [],
38
        ?Annotation $annotation = null,
39
        ?IDValue $id = null,
40
        array $namespacedAttributes = [],
41
    ) {
42
        if ($minOccurs !== null) {
43
            Assert::oneOf($minOccurs->toInteger(), [0, 1], SchemaViolationException::class);
44
        }
45
46
        if ($maxOccurs !== null) {
47
            Assert::same($maxOccurs->toInteger(), 1, SchemaViolationException::class);
48
        }
49
50
        Assert::allIsInstanceOf(
51
            $particles,
52
            NarrowMaxMinElement::class,
53
            SchemaViolationException::class,
54
        );
55
56
        parent::__construct(
57
            nestedParticles: $particles,
58
            minOccurs: $minOccurs,
59
            maxOccurs: $maxOccurs,
60
            annotation: $annotation,
61
            id: $id,
62
            namespacedAttributes: $namespacedAttributes,
63
        );
64
    }
65
}
66