Passed
Pull Request — master (#374)
by Tim
03:49 queued 01:20
created

SAMLDateTimeValue::validateValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\Type;
6
7
use SimpleSAML\SAML2\Assert\Assert;
8
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
9
use SimpleSAML\XML\Type\DateTimeValue;
10
11
/**
12
 * @package simplesaml/saml2
13
 */
14
class SAMLDateTimeValue extends DateTimeValue
15
{
16
    // Lowercase p as opposed to the base-class to covert the timestamp to UTC as demanded by the SAML specifications
17
    public const DATETIME_FORMAT = 'Y-m-d\\TH:i:sp';
18
19
20
    /**
21
     * Validate the value.
22
     *
23
     * @param string $value
24
     * @return void
25
     */
26
    protected function validateValue(string $value): void
27
    {
28
        // Note: value must already be sanitized before validating
29
        Assert::validSAMLDateTime($this->sanitizeValue($value), ProtocolViolationException::class);
30
    }
31
}
32