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

HexBinaryValue   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sanitizeValue() 0 3 1
A validateValue() 0 5 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