OptionalTrait::setOptional()   A
last analyzed

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
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\WSSecurity\XML\wsp;
6
7
/**
8
 * Trait grouping common functionality for elements that can hold an Optional attribute.
9
 *
10
 * @package simplesamlphp/ws-security
11
 */
12
trait OptionalTrait
13
{
14
    /**
15
     * The Optional.
16
     *
17
     * @var bool
18
     */
19
    protected bool $Optional;
20
21
22
    /**
23
     * Collect the value of the Optional-property
24
     *
25
     * @return bool
26
     */
27
    public function getOptional(): bool
28
    {
29
        return $this->Optional;
30
    }
31
32
33
    /**
34
     * Set the value of the Optional-property
35
     *
36
     * @param bool $Optional
37
     */
38
    protected function setOptional(?bool $Optional): void
39
    {
40
        $this->Optional = $Optional ?? false;
41
    }
42
}
43