IDRefsValue   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validateValue() 0 4 1
A toArray() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSchema\Type;
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\Interface\ListTypeInterface;
11
12
/**
13
 * @package simplesaml/xml-common
14
 */
15
class IDRefsValue extends TokenValue implements ListTypeInterface
16
{
17
    /** @var string */
18
    public const SCHEMA_TYPE = 'IDREFS';
19
20
21
    /**
22
     * Validate the value.
23
     *
24
     * @param string $value
25
     * @throws \SimpleSAML\XMLSchema\Exception\SchemaViolationException on failure
26
     * @return void
27
     */
28
    protected function validateValue(string $value): void
29
    {
30
        // Note: value must already be sanitized before validating
31
        Assert::validIDRefs($this->sanitizeValue($value), SchemaViolationException::class);
32
    }
33
34
35
    /**
36
     * Convert this xs:IDREFS to an array of xs:IDREF items
37
     *
38
     * @return array<\SimpleSAML\XMLSchema\Type\IDRefValue>
39
     */
40
    public function toArray(): array
41
    {
42
        $tokens = explode(' ', $this->getValue(), C::UNBOUNDED_LIMIT);
43
        return array_map([IDRefValue::class, 'fromString'], $tokens);
44
    }
45
}
46