Passed
Branch master (c7ca4c)
by Tim
16:17 queued 14:33
created

BlockSetValue   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSchema\Type\Schema;
6
7
use SimpleSAML\XML\Assert\Assert;
8
use SimpleSAML\XML\Constants as C;
9
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
10
use SimpleSAML\XMLSchema\Type\NMTokenValue;
11
use SimpleSAML\XMLSchema\XML\Enumeration\DerivationControlEnum;
12
13
use function explode;
14
15
/**
16
 * @package simplesaml/xml-common
17
 */
18
class BlockSetValue extends NMTokenValue
19
{
20
    public const string SCHEMA_TYPE = 'blockSet';
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 20 at column 24
Loading history...
21
22
23
    /**
24
     * Validate the value.
25
     *
26
     * @param string $value The value
27
     * @throws \Exception on failure
28
     */
29
    protected function validateValue(string $value): void
30
    {
31
        $sanitized = $this->sanitizeValue($value);
32
33
        if ($sanitized !== '#all' && $sanitized !== '') {
34
            $list = explode(' ', $sanitized, C::UNBOUNDED_LIMIT);
35
36
            // After filtering the allowed values, there should be nothing left
37
            $filtered = array_diff(
38
                $list,
39
                [
40
                    DerivationControlEnum::Extension->value,
41
                    DerivationControlEnum::Restriction->value,
42
                    DerivationControlEnum::Substitution->value,
43
                ],
44
            );
45
            Assert::isEmpty($filtered, SchemaViolationException::class);
46
        }
47
    }
48
}
49