Passed
Pull Request — master (#61)
by Tim
02:20
created

AttrDeclsTrait::setAnyAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
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
10
/**
11
 * Trait grouping common functionality for elements that use the attrDecls-group.
12
 *
13
 * @package simplesamlphp/xml-common
14
 */
15
trait AttrDeclsTrait
16
{
17
    /**
18
     * The attributes + groups.
19
     *
20
     * @var (
1 ignored issue
show
Documentation Bug introduced by
The doc comment ( at position 1 could not be parsed: the token is null at position 1.
Loading history...
21
     *     \SimpleSAML\XMLSchema\XML\xs\LocalAttribute|
22
     *     \SimpleSAML\XMLSchema\XML\xs\ReferencedAttributeGroup
23
     * )[] $attributes
24
     */
25
    protected array $attributes = [];
26
27
    /**
28
     * The AnyAttribute
29
     *
30
     * @var \SimpleSAML\XMLSchema\XML\xs\AnyAttribute|null $anyAttribute
31
     */
32
    protected ?AnyAttribute $anyAttribute = null;
33
34
35
    /**
36
     * Collect the value of the attributes-property
37
     *
38
     * @return (
1 ignored issue
show
Documentation Bug introduced by
The doc comment ( at position 1 could not be parsed: the token is null at position 1.
Loading history...
39
     *     \SimpleSAML\XMLSchema\XML\xs\LocalAttribute|
40
     *     \SimpleSAML\XMLSchema\XML\xs\ReferencedAttributeGroup
41
     * )[]
42
     */
43
    public function getAttributes(): array
44
    {
45
        return $this->attributes;
46
    }
47
48
49
    /**
50
     * Collect the value of the anyAttribute-property
51
     *
52
     * @return \SimpleSAML\XMLSchema\XML\xs\AnyAttribute|null
53
     */
54
    public function getAnyAttribute(): ?AnyAttribute
55
    {
56
        return $this->anyAttribute;
57
    }
58
59
60
    /**
61
     * Set the value of the attributes-property
62
     *
63
     * @param (
64
     *     \SimpleSAML\XMLSchema\XML\xs\LocalAttribute|
65
     *     \SimpleSAML\XMLSchema\XML\xs\ReferencedAttributeGroup
66
     * )[] $attributes
67
     */
68
    protected function setAttributes(array $attributes): void
69
    {
70
        Assert::allIsInstanceOfAny(
71
            $attributes,
72
            [LocalAttribute::class, ReferencedAttributeGroup::class],
73
            SchemaViolationException::class,
74
        );
75
76
        $this->attributes = $attributes;
77
    }
78
79
80
    /**
81
     * Set the value of the anyAttribute-property
82
     *
83
     * @param \SimpleSAML\XMLSchema\XML\xs\AnyAttribute|null $anyAttribute
84
     */
85
    protected function setAnyAttribute(?AnyAttribute $anyAttribute): void
86
    {
87
        $this->anyAttribute = $anyAttribute;
88
    }
89
}
90