ProcessContentsValue::validateValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
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\Type\NMTokenValue;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSchema\Type\NMTokenValue 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...
10
use SimpleSAML\XMLSchema\XML\Enumeration\ProcessContentsEnum;
11
12
use function array_column;
13
14
/**
15
 * @package simplesaml/xml-common
16
 */
17
class ProcessContentsValue extends NMTokenValue
18
{
19
    /**
20
     * Validate the value.
21
     *
22
     * @param string $value The value
23
     * @throws \SimpleSAML\XMLSchema\Exception\SchemaViolationException on failure
24
     */
25
    protected function validateValue(string $value): void
26
    {
27
        Assert::oneOf(
28
            $this->sanitizeValue($value),
29
            array_column(ProcessContentsEnum::cases(), 'value'),
30
            SchemaViolationException::class,
31
        );
32
    }
33
34
35
    /**
36
     * @param \SimpleSAML\XMLSchema\XML\Enumeration\ProcessContentsEnum $value
37
     */
38
    public static function fromEnum(ProcessContentsEnum $value): static
39
    {
40
        return new static($value->value);
41
    }
42
43
44
    /**
45
     * @return \SimpleSAML\XMLSchema\XML\Enumeration\ProcessContentsEnum $value
46
     */
47
    public function toEnum(): ProcessContentsEnum
48
    {
49
        return ProcessContentsEnum::from($this->getValue());
50
    }
51
}
52