Passed
Pull Request — master (#55)
by Tim
01:56
created

IDRefsValue   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 25
rs 10

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\XML\Type;
6
7
use SimpleSAML\XML\Assert\Assert;
8
use SimpleSAML\XML\Constants as C;
9
use SimpleSAML\XML\Exception\SchemaViolationException;
10
11
/**
12
 * @package simplesaml/xml-common
13
 */
14
class IDRefsValue extends TokenValue implements ListTypeInterface
15
{
16
    /**
17
     * Validate the value.
18
     *
19
     * @param string $value
20
     * @throws \SimpleSAML\XML\Exception\SchemaViolationException on failure
21
     * @return void
22
     */
23
    protected function validateValue(string $value): void
24
    {
25
        // Note: value must already be sanitized before validating
26
        Assert::validIDRefs($this->sanitizeValue($value), SchemaViolationException::class);
27
    }
28
29
30
    /**
31
     * Convert this xs:IDREFS to an array of xs:IDREF items
32
     *
33
     * @return array<\SimpleSAML\XML\Type\IDRefValue>
34
     */
35
    public function toArray(): array
36
    {
37
        $tokens = explode(' ', $this->getValue(), C::UNBOUNDED_LIMIT);
38
        return array_map([IDRefValue::class, 'fromString'], $tokens);
39
    }
40
}
41