IndexedElementTrait::getIsDefault()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\md;
6
7
use SimpleSAML\Assert\Assert;
8
9
/**
10
 * Trait adding methods to handle elements that can be indexed.
11
 *
12
 * @package simplesamlphp/saml2
13
 */
14
trait IndexedElementTrait
15
{
16
    /**
17
     * The index for this endpoint.
18
     *
19
     * @var int
20
     */
21
    protected int $index;
22
23
    /**
24
     * Whether this endpoint is the default.
25
     *
26
     * @var bool|null
27
     */
28
    protected ?bool $isDefault = null;
29
30
31
    /**
32
     * Collect the value of the index property.
33
     *
34
     * @return int
35
     */
36
    public function getIndex(): int
37
    {
38
        return $this->index;
39
    }
40
41
42
    /**
43
     * Set the value of the index property.
44
     *
45
     * @param int $index
46
     * @throws \SimpleSAML\Assert\AssertionFailedException
47
     */
48
    protected function setIndex(int $index): void
49
    {
50
        Assert::range($index, 0, 65535);
51
        $this->index = $index;
52
    }
53
54
55
    /**
56
     * Collect the value of the isDefault property.
57
     *
58
     * @return bool|null
59
     */
60
    public function getIsDefault(): ?bool
61
    {
62
        return $this->isDefault;
63
    }
64
65
66
    /**
67
     * Set the value of the isDefault property.
68
     *
69
     * @param bool|null $flag
70
     */
71
    protected function setIsDefault(?bool $flag): void
72
    {
73
        $this->isDefault = $flag;
74
    }
75
}
76