Passed
Push — master ( faa376...c7ca4c )
by Tim
17:29 queued 14:52
created

SimpleDerivationSetValue   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 29
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\XMLSchema\Exception\SchemaViolationException;
9
use SimpleSAML\XMLSchema\XML\Enumeration\DerivationControlEnum;
10
11
use function array_column;
12
use function explode;
13
14
/**
15
 * @package simplesaml/xml-common
16
 */
17
class SimpleDerivationSetValue extends DerivationControlValue
18
{
19
    public const string SCHEMA_TYPE = 'simpleDerivationSet';
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 19 at column 24
Loading history...
20
21
22
    /**
23
     * Validate the value.
24
     *
25
     * @param string $value The value
26
     * @throws \SimpleSAML\XMLSchema\Exception\SchemaViolationException on failure
27
     */
28
    protected function validateValue(string $value): void
29
    {
30
        $sanitized = $this->sanitizeValue($value);
31
32
        if ($sanitized !== '#all' && $sanitized !== '') {
33
            Assert::allOneOf(
34
                explode(' ', $sanitized),
35
                array_column(
36
                    [
37
                        DerivationControlEnum::List,
38
                        DerivationControlEnum::Restriction,
39
                        DerivationControlEnum::Union,
40
                    ],
41
                    'value',
42
                ),
43
                SchemaViolationException::class,
44
            );
45
        }
46
    }
47
}
48