MonthValue::sanitizeValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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 MonthValue extends AbstractAnySimpleType
15
{
16
    /** @var string */
17
    public const SCHEMA_TYPE = 'gMonth';
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::validMonth($this->sanitizeValue($value), SchemaViolationException::class);
42
    }
43
}
44