AttrDeclsTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 74
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setAttributes() 0 10 1
A setAnyAttribute() 0 3 1
A getAttributes() 0 3 1
A getAnyAttribute() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSchema\XML\Trait;
6
7
use SimpleSAML\XML\Assert\Assert;
8
use SimpleSAML\XML\Constants as C;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XML\Constants was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
10
use SimpleSAML\XMLSchema\XML\AnyAttribute;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSchema\XML\AnyAttribute was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use SimpleSAML\XMLSchema\XML\LocalAttribute;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSchema\XML\LocalAttribute was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use SimpleSAML\XMLSchema\XML\ReferencedAttributeGroup;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSchema\XML\ReferencedAttributeGroup was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
/**
15
 * Trait grouping common functionality for elements that use the attrDecls-group.
16
 *
17
 * @package simplesamlphp/xml-common
18
 */
19
trait AttrDeclsTrait
20
{
21
    /**
22
     * The attributes + groups.
23
     *
24
     * @var (
25
     *     \SimpleSAML\XMLSchema\XML\LocalAttribute|
26
     *     \SimpleSAML\XMLSchema\XML\ReferencedAttributeGroup
27
     * )[] $attributes
28
     */
29
    protected array $attributes = [];
30
31
    /**
32
     * The AnyAttribute
33
     *
34
     * @var \SimpleSAML\XMLSchema\XML\AnyAttribute|null $anyAttribute
35
     */
36
    protected ?AnyAttribute $anyAttribute = null;
37
38
39
    /**
40
     * Collect the value of the attributes-property
41
     *
42
     * @return (
43
     *     \SimpleSAML\XMLSchema\XML\LocalAttribute|
44
     *     \SimpleSAML\XMLSchema\XML\ReferencedAttributeGroup
45
     * )[]
46
     */
47
    public function getAttributes(): array
48
    {
49
        return $this->attributes;
50
    }
51
52
53
    /**
54
     * Collect the value of the anyAttribute-property
55
     *
56
     * @return \SimpleSAML\XMLSchema\XML\AnyAttribute|null
57
     */
58
    public function getAnyAttribute(): ?AnyAttribute
59
    {
60
        return $this->anyAttribute;
61
    }
62
63
64
    /**
65
     * Set the value of the attributes-property
66
     *
67
     * @param (
68
     *     \SimpleSAML\XMLSchema\XML\LocalAttribute|
69
     *     \SimpleSAML\XMLSchema\XML\ReferencedAttributeGroup
70
     * )[] $attributes
71
     */
72
    protected function setAttributes(array $attributes): void
73
    {
74
        Assert::maxCount($attributes, C::UNBOUNDED_LIMIT);
75
        Assert::allIsInstanceOfAny(
76
            $attributes,
77
            [LocalAttribute::class, ReferencedAttributeGroup::class],
78
            SchemaViolationException::class,
79
        );
80
81
        $this->attributes = $attributes;
82
    }
83
84
85
    /**
86
     * Set the value of the anyAttribute-property
87
     *
88
     * @param \SimpleSAML\XMLSchema\XML\AnyAttribute|null $anyAttribute
89
     */
90
    protected function setAnyAttribute(?AnyAttribute $anyAttribute): void
91
    {
92
        $this->anyAttribute = $anyAttribute;
93
    }
94
}
95