Completed
Push — master ( b4a32a...a386bd )
by Tim
18s queued 14s
created

HexBinaryValue::sanitizeValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 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\Exception\SchemaViolationException;
9
10
/**
11
 * @package simplesaml/xml-common
12
 */
13
class HexBinaryValue extends AbstractValueType
14
{
15
    /** @var string */
16
    public const SCHEMA_TYPE = 'hexBinary';
17
18
19
    /**
20
     * Sanitize the value.
21
     *
22
     * @param string $value  The unsanitized value
23
     * @return string
24
     */
25
    protected function sanitizeValue(string $value): string
26
    {
27
        return static::collapseWhitespace(static::normalizeWhitespace($value));
28
    }
29
30
31
    /**
32
     * Validate the value.
33
     *
34
     * @param string $value
35
     * @throws \SimpleSAML\XML\Exception\SchemaViolationException on failure
36
     * @return void
37
     */
38
    protected function validateValue(string $value): void
39
    {
40
        Assert::validHexBinary(
41
            $this->sanitizeValue($value),
42
            SchemaViolationException::class,
43
        );
44
    }
45
}
46