DayValue   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sanitizeValue() 0 3 1
A validateValue() 0 3 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\XMLSchema\Exception\SchemaViolationException;
9
use SimpleSAML\XMLSchema\Type\Interface\AbstractAnySimpleType;
10
11
/**
12
 * @package simplesaml/xml-common
13
 */
14
class DayValue extends AbstractAnySimpleType
15
{
16
    /** @var string */
17
    public const SCHEMA_TYPE = 'gDay';
18
19
20
    /**
21
     * Sanitize the value.
22
     *
23
     * @param string $value  The unsanitized value
24
     * @return string
25
     */
26
    protected function sanitizeValue(string $value): string
27
    {
28
        return static::collapseWhitespace(static::normalizeWhitespace($value));
29
    }
30
31
32
    /**
33
     * Validate the value.
34
     *
35
     * @param string $value
36
     * @throws \SimpleSAML\XMLSchema\Exception\SchemaViolationException on failure
37
     * @return void
38
     */
39
    protected function validateValue(string $value): void
40
    {
41
        Assert::validDay($this->sanitizeValue($value), SchemaViolationException::class);
42
    }
43
}
44